在横向显示视图
问题描述:
我正在显示一个视频,我需要视图进行旋转以便以横向显示。我写了下面的代码,它正是我想要的。问题是,当我点击后退按钮时(显示运营商和时间标题的栏)仍为横向(对于假设为纵向的视图)。我如何纠正这一点?在横向显示视图
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
答
现在只要把你的帧新的位置,即:
-(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;
}
答
是否定义:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
用于其观点,就是要肖像控制器? (您在关闭视频后返回的那个)