首页 文章

iPad presentViewController总是全屏(需要formSheet)iOS6

提问于
浏览
7

当用户点击我的通用应用程序的iPad侧的导航栏中的'settings'按钮时,我需要将viewController呈现为 formSheet . 该视图名为"SettingsViewController,",它是我的iPad故事板中的视图控制器,ID为"settings" .

我没有使用segue,因为在我的iPad版本的应用程序中,我在左侧的导航栏中有多个按钮,所以我必须按程序添加按钮 . (无法将segue连接到故事板中不存在的UIBarButtonItem . )

我想要的功能在那里,演示文稿不是 . 当我在iPad上展示我的 SettingsViewController 时,它呈现为全屏视图 . 我需要它作为表单 .

我将它包装在一个 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 回答

  • 20

    看起来您在 SettingsViewController 上设置了模态演示文稿样式,但您应该在 UINavigationController 上设置它 .

  • 6
    navcont.modalPresentationStyle = UIModalPresentationFormSheet;
    

相关问题