我正在显示视频,我需要旋转视图,以便以横向显示。我写了下面的代码,它完全符合我的要求。问题是,当我单击后退按钮时,(载体标题和时间显示的栏)仍然是横向(对于假设为肖像的视图)。我该如何纠正这个?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
答案 0 :(得分:0)
现在只需将您的框架放入新位置,即:
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
if(self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
self.interfaceOrientation == UIInterfaceOrientationLandscapeRight){
video1.frame = CGRectMake(50, 650, 150, 30);
video2.frame = CGRectMake(350, 650, 150, 30);
} else {
video1.frame = CGRectMake(10, 10, 150, 30);
video2.frame = CGRectMake(610, 10, 150, 30);
}
}
并留下它的样子
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
可以调用您希望它更改的方法中的方向。所以它知道..
示例:
-(void)videoDisplayMothod {
//video code
toInterfaceOrientation = UIInterfaceOrientationLandscapeLeft;
}
答案 1 :(得分:0)
你有没有定义:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
对于视图为肖像的控制器? (关闭视频后你回去的那个)