【问题标题】:iPad presentViewController is always Fullscreen (need formSheet) iOS6iPad presentViewController 总是全屏(需要表单)iOS 6
【发布时间】:2012-12-02 01:24:05
【问题描述】:

当用户点击我的通用应用程序 iPad 端导航栏中的“设置”按钮时,我需要将 viewController 呈现为 formSheet。该视图称为“SettingsViewController”,它是我的 iPad Storyboard 中的一个视图控制器,其 ID 为“settings”。

我没有使用 segues,因为在我的 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];

}

我已经尝试了我能想到的一切。非常感谢任何帮助。

【问题讨论】:

    标签: ios xcode ipad storyboard presentmodalviewcontroller


    【解决方案1】:

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

    【讨论】:

    • 是的,就是这样。谢谢。
    【解决方案2】:
    navcont.modalPresentationStyle = UIModalPresentationFormSheet;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-27
      • 2012-10-01
      • 1970-01-01
      • 2021-10-20
      相关资源
      最近更新 更多