我正在设计一个应用程序,其中我有一个表视图控制器。现在我希望当我旋转设备然后而不是表视图时,将出现带有页面控件的滚动。这样我就可以使用页面控件滚动图像。
当我再次旋转到纵向模式时,它将再次表格视图。
- (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;
}
我如何实现这一目标?
答案 0 :(得分:0)
您可以实现didRotateFromInterfaceOrientation来检测屏幕何时旋转,然后添加您的代码以根据当前方向添加/显示/删除/隐藏/您的任何视图。
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
switch (self.interfaceOrientation) {
case UIInterfaceOrientationPortrait:
//Do stuff
break;
default:
break;
}
}
self.interfaceOrientation提供当前方向,(纵向,倒置,landscapeleft,landscaperight),如果需要,您还可以访问上一个方向。