首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >presentModalViewController的问题

presentModalViewController的问题
EN

Stack Overflow用户
提问于 2010-05-14 19:28:30
回答 3查看 4.9K关注 0票数 5

如果我的iPad处于横向模式,并且调用了presentModalViewController,则视图会自动转换为纵向模式。有什么解决方案吗?

代码语言:javascript
复制
UIViewController * start = [[UIViewController alloc]initWithNibName:@"SecondView" bundle:nil];
start.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
start.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:start animated:YES];

在SecondView中,我已经添加了:

代码语言:javascript
复制
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2011-09-07 05:53:11

问题是您的示例代码创建的是UIViewController,而不是实际的派生类。换句话说,你应该像这样创建你的控制器:

代码语言:javascript
复制
SecondViewController *start = [[SecondViewController alloc]initWithNibName:@"SecondView" bundle:nil];

我假设您的视图控制器类被称为"SecondViewController“,因为您使用类似的名称加载了一个nib。

如果你没有提供正确的实例,你的委托方法就无法被调用。

票数 2
EN

Stack Overflow用户

发布于 2011-05-20 17:37:20

您的UIViewController 'start‘必须重写才能使其显示在正确的方向上。

代码语言:javascript
复制
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations.
    return YES;//UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

我刚刚遇到了这个问题。我用这种方法解决了这个问题。希望这也能对你有所帮助。

票数 1
EN

Stack Overflow用户

发布于 2010-11-03 03:27:53

一定还有其他的原因,因为在IB中定义对我来说也不起作用。原始OP是否使用splitViewController?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2833740

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档