2011-11-15 28 views
0

我正在设计一个应用程序,其中我有一个表视图控制器。现在我想要的是,当我旋转设备,而不是表格视图时,会出现一个页面控件的滚动。这样我就可以通过页面控制来滚动图片。当设备向左或向右旋转时,如何使用页面控件添加滚动视图?

而当我再次旋转到肖像模式,那么它会再次表格视图。

- (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

您可以实现didRotateFromInterfaceOrientation来检测屏幕何时旋转,然后添加您的代码以基于当前方向添加/显示/删除/隐藏/您的视图。

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { 
    switch (self.interfaceOrientation) { 
     case UIInterfaceOrientationPortrait: 
      //Do stuff 
      break; 

     default: 
      break; 
    } 
} 

self.interfaceOrientation给当前的方向,(肖像,倒置,landscapeleft,landscaperight),你也可以访问前的姿态,如果你需要它。

相关问题