iPad的presentViewController始终是全屏显示(需要FormSheet)iOS6

7
当用户在我的通用应用程序的iPad侧面点击“设置”按钮时,我需要将一个名为“SettingsViewController”的视图控制器作为formSheet呈现。该视图是我的iPad Storyboard中的一个视图控制器,其ID为“settings”。
由于我在iPad版本的应用程序中,在左侧导航栏上有多个按钮,因此我不能使用segues。我必须以编程方式添加按钮。(无法将segue连接到Storyboard中不存在的UIBarButtonItem。)
我需要的功能已经实现,但呈现方式不正确。当我展示我的SettingsViewController时,在iPad上它会呈现为全屏视图,而我需要它成为一个表单。
我将其包装在一个NavigationController中,这是我需要的并且也可以正常工作,只需要以正确的方式呈现即可。
以下是呈现视图的代码:
-(void)showSettings:(id)sender {

    SettingsViewController *svc = [self.storyboard instantiateViewControllerWithIdentifier:@"settings"];
    svc.delegate = self;
    svc.modalPresentationStyle = UIModalPresentationFormSheet;
    UINavigationController *navcont = [[UINavigationController alloc] initWithRootViewController:svc];
    [self presentViewController:navcont animated:YES completion:NULL];

}

我尝试了所有我能想到的方法。非常感谢您的帮助。
2个回答

24

看起来你将模态呈现样式设置在了SettingsViewController上,但你应该将其设置在你的UINavigationController上。


6
navcont.modalPresentationStyle = UIModalPresentationFormSheet;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接