【发布时间】: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