2016-11-12 67 views
0

我正在用一些屏幕构建一个视频应用程序,我希望所有这些屏幕只允许肖像,除了可以手动从纵向移动到风景的视频播放器屏幕。需要帮助修复某些UIViewControllers的方向

现在我在视频播放器屏幕下面

#pragma mark - CHANGE ORIENTATION METHODS 


- (void)changeOrientation { 

NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]; 
[[UIDevice currentDevice] setValue:value forKey:@"orientation"]; 

} 

然后在清单屏,我有以下尝试和固定取向只肖像。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

现在,当我加载应用程序似乎设置为纵向,问题是在视频播放器屏幕上,我有一个后退按钮。如果屏幕处于横向模式和我点击后面的

shouldAutorotateToInterfaceOrientation

不会被调用,它是停留在横向模式。

我该如何强制它调用上述方法,还是有更好的方法来处理这个问题?由于

回答

0

你可以尝试迫使编程姿势的改变:

-(void)viewWillAppear:(BOOL)animated { 
    NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]; 
    [[UIDevice currentDevice] setValue:value forKey:@"orientation"]; 
} 

当然,你需要确保您的项目靶>部署信息 - >设备方向的横向放置。我希望它有帮助。