xcode iPad presentViewController 总是全屏(需要 formSheet)iOS6
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13871968/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iPad presentViewController is always Fullscreen (need formSheet) iOS6
提问by jhilgert00
I need to present a viewController as a formSheet
when the user taps a 'settings' button in the navigation bar in the iPad side of my universal app. The view is called "SettingsViewController," and it's a View Controller in my iPad Storyboard with an ID of "settings".
formSheet
当用户点击我的通用应用程序 iPad 侧导航栏中的“设置”按钮时,我需要将一个 viewController 呈现为一个。该视图称为“SettingsViewController”,它是我 iPad Storyboard 中的一个视图控制器,ID 为“settings”。
I'm not using segues because in my iPad version of the app, I have more than one button in the navigation bar on the left side, so I have to add the buttons progammatically. (can't connect a segue to a nonexistent UIBarButtonItem in the storyboard.)
我没有使用 segues,因为在我的 iPad 版本的应用程序中,我在左侧的导航栏中有多个按钮,所以我必须以编程方式添加按钮。(无法将 segue 连接到故事板中不存在的 UIBarButtonItem。)
The functionality I want is there, the presentation is not.
When I present my SettingsViewController
, on the iPad, it's presenting as a full screen view.
I need it to be a form sheet.
我想要的功能在那里,演示文稿不在。当我SettingsViewController
在 iPad 上展示我的 时,它以全屏视图的形式展示。我需要它是一个表格。
I'm wrapping it in a NavigationController
, which I need and works fine, just need it to present itself in the correct manner.
我将它包装在一个NavigationController
,我需要并且工作正常,只需要它以正确的方式呈现自己。
Here's the code that presents the view:
这是呈现视图的代码:
-(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];
}
I've tried everything I can think of. Any help is deeply appreciated.
我已经尝试了所有我能想到的。任何帮助深表感谢。
回答by geraldWilliam
Looks like you set the modal presentation style on SettingsViewController
but you should have set it on your UINavigationController
.
看起来您将模态演示样式设置为打开,SettingsViewController
但您应该将其设置在UINavigationController
.
回答by Gank
navcont.modalPresentationStyle = UIModalPresentationFormSheet;