2014-11-21 76 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

相關問題