Iphone 横向显示视图
我正在显示一个视频,我需要旋转视图,使其以横向方向显示。我写了下面的代码,它完全符合我的要求。问题是,当我单击后退按钮时,(显示载体标题和时间的栏)仍然是横向的(对于假定为纵向的视图)。我如何纠正这个问题Iphone 横向显示视图,iphone,objective-c,cocoa-touch,Iphone,Objective C,Cocoa Touch,我正在显示一个视频,我需要旋转视图,使其以横向方向显示。我写了下面的代码,它完全符合我的要求。问题是,当我单击后退按钮时,(显示载体标题和时间的栏)仍然是横向的(对于假定为纵向的视图)。我如何纠正这个问题 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations retu
- (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);
}
对于视图为纵向的控制器?(关闭视频后返回的那个)