如果我的iPad处于横向模式,并且调用了presentModalViewController,则视图会自动转换为纵向模式。有什么解决方案吗?
UIViewController * start = [[UIViewController alloc]initWithNibName:@"SecondView" bundle:nil];
start.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
start.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:start animated:YES];在SecondView中,我已经添加了:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}发布于 2011-09-07 05:53:11
问题是您的示例代码创建的是UIViewController,而不是实际的派生类。换句话说,你应该像这样创建你的控制器:
SecondViewController *start = [[SecondViewController alloc]initWithNibName:@"SecondView" bundle:nil];我假设您的视图控制器类被称为"SecondViewController“,因为您使用类似的名称加载了一个nib。
如果你没有提供正确的实例,你的委托方法就无法被调用。
发布于 2011-05-20 17:37:20
您的UIViewController 'start‘必须重写才能使其显示在正确的方向上。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations.
return YES;//UIInterfaceOrientationIsLandscape(interfaceOrientation);
}我刚刚遇到了这个问题。我用这种方法解决了这个问题。希望这也能对你有所帮助。
发布于 2010-11-03 03:27:53
一定还有其他的原因,因为在IB中定义对我来说也不起作用。原始OP是否使用splitViewController?
https://stackoverflow.com/questions/2833740
复制相似问题