如何在dismissModalViewController后设置方向以纠正设备方向?

时间:2012-05-18 10:29:08

标签: ios uiviewcontroller rotation orientation landscape-portrait

我有一个显示内容的详细视图。使用按钮我会以模态方式呈现另一个视图:

[self.viewController presentModalViewController:helpViewController animated:NO];  

所以,当我关闭这个helpViewController时,detailview总是在portraitMode中 无法使其达到正确的设备方向。

我已尝试将其旋转到设备方向:

if ([UIViewController respondsToSelector:@selector(  
    attemptRotationToDeviceOrientation)]) {

    [UIViewController attemptRotationToDeviceOrientation];
}  

似乎在解除了helpViewController之后,viewDidAppear没有在detailView中调用 那我怎么能让它发挥作用呢?

1 个答案:

答案 0 :(得分:1)

Plz尝试将detailview.m设置为

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
{
// Return YES for supported orientations
return YES;
//    return (interfaceOrientation == UIInterfaceOrientationPortrait);

}
相关问题