实际上删除和插入这里提到不工作的窗口视图第一视图的方法! iOS portrait only app returns from UIWebview youtube in landscape
我只是需要从某种原因不要求窗口子视图中的第一个视图。我需要自己提供根视图。
所以我的解决方案是实现在支持两个方向视图控制器下面的方法:
-(void)viewWillAppear:(BOOL)animated
{
m_b_avoid_landscape_orinetation = NO;
[super viewWillAppear:animated];
}
-(void)viewWillDisappear:(BOOL)animated
{
m_b_avoid_landscape_orinetation = YES;
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
[[self getTabBar].view removeFromSuperview];
[window addSubview:[self getTabBar].view];
[super viewWillDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
if (m_b_avoid_landscape_orinetation)
return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
else
return YES;
}
其中[自getTabBar]提供的作品作为窗口的子视图第一个视图我的自定义标签栏。
编辑因此,与iOS 6不再起作用。我使用了解决方案,使用新的supportedInterfaceOrientations方法插入和删除模态对话框,如其他地方所述。
-(void)goBack
{
m_b_avoid_landscpae_orinetation = YES;
UIViewController *viewController = [[UIViewController alloc] init];
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
[window.rootViewController presentViewController:viewController animated:NO completion:^{
[viewController dismissModalViewControllerAnimated:NO];
}];
[self.navigationController popViewControllerAnimated:YES];
}
-(NSUInteger)supportedInterfaceOrientations
{
if (m_b_avoid_landscpae_orinetation)
return UIInterfaceOrientationMaskPortrait;
return UIInterfaceOrientationMaskAllButUpsideDown;
}
我也许错过了一些东西。当我呈现视图控制器modaly(与presentModalViewController :)它不会旋转,无论是在shouldAutorotateToInterfaceOrientation: – Engeor
我使用故事板,这里是我如何呈现我的视图控制器,它在上面的代码是它的作品好。 'UIStoryboard * storyboard = self.storyboard; FullScreenPhoto * fullScreen = [storyboard instantiateViewControllerWithIdentifier:@“full”]; //我的图像视图设置 [self presentModalViewController:fullScreen animated:YES]; ' – Pitono
哦,我还是不使用故事板。无论如何,谢谢你的努力。 – Engeor