当设备向左或向右旋转时,如何添加带有页面控制的滚动视图?
我正在设计一个应用程序,其中有一个表视图控制器。现在我希望当我旋转设备时,将出现带有页面控制的滚动而不是表格视图。这样我就可以用页面控制滚动图像。
当我再次旋转到纵向模式时,表格视图也会如此。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
// Return YES for supported orientations
if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight){
self.navigationController.navigationBarHidden=TRUE;
self.tabBarController.tabBar.hidden=TRUE;
}
else{
self.navigationController.navigationBarHidden=FALSE;
self.tabBarController.tabBar.hidden=FALSE;
self.tableView.hidden=FALSE;
}
return YES;
}
我该如何实现这一目标?
I am designing an application in which i have a table view controller. Now I want that when I rotate device then instead of table view a scroll with page control will appear. So that I can scroll image with page control.
And when I again rotate to portrait mode then it will so again table view.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
// Return YES for supported orientations
if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight){
self.navigationController.navigationBarHidden=TRUE;
self.tabBarController.tabBar.hidden=TRUE;
}
else{
self.navigationController.navigationBarHidden=FALSE;
self.tabBarController.tabBar.hidden=FALSE;
self.tableView.hidden=FALSE;
}
return YES;
}
How do I achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以实现 didRotateFromInterfaceOrientation 来检测屏幕何时旋转,然后添加代码以根据当前方向添加/显示/删除/隐藏/任何视图。
self.interfaceOrientation 给出当前方向(纵向、倒置、横向左、横向右),如果需要,您还可以访问之前的方向。
You can implement didRotateFromInterfaceOrientation to detect when the screen rotates, then add your code to add/show/remove/hide/whatever your views based on the current orientation.
self.interfaceOrientation gives the current orientation, (portrait, upsidedown, landscapeleft, landscaperight), and you also have access to the previous orientation if you need it.