2014-11-21 53 views
0

我试图保持UITableViewcontroller纵向。因此,我不想旋转到横向模式。我在下面添加了方法。但它并没有帮助,请注意,我使用的是iOS 8:禁用UITableViewcontroller在横向旋转(保持纵向)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    if(interfaceOrientation== UIInterfaceOrientationPortrait) 
    { 
     return YES; 
    }else 
    { 
     return NO; 
    } 

} 

通知,我通过调用的UITableView UINavigationController的

UINavigationController *navigationController = [[UINavigationController alloc] 
                initWithRootViewController:svc]; 
    // configure the new view controller explicitly here. 

    [self presentViewController:navigationController animated:YES completion: nil]; 
+0

你的意思是你想UIInterfaceOrientationPortraitUpsideDown? – faviomob 2014-11-21 19:40:19

+0

不,我只是不想让视图旋转到风景。 – user836026 2014-11-21 20:04:34

+0

您可以在info.plist中设置可用的旋转模式 – faviomob 2014-11-21 20:05:56

回答

1

您可以设置启用定向接口在Info.plist中,或者如果您只希望以这种方式使用表格,则在呈现视图时必须手动修改navigationController中的supportInterfaceOrientation。 '孩子'将承担navigationController的值。然后,当您关闭桌子时,您必须手动重置supportInterfaceOrientation

相关问题