要做视频播放的视图,要求横屏播放可是我的整个应用是只支持竖屏 ios5下在视频视图横屏用
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);
}可是ios6下横屏怎么写?谢谢
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);
}可是ios6下横屏怎么写?谢谢
Returns a Boolean value indicating whether the view controller supports the specified orientation. (Deprecated in iOS 6.0. Override the supportedInterfaceOrientations and preferredInterfaceOrientationForPresentation methods instead.)
重载supportedInterfaceOrientations 和 preferredInterfaceOrientationForPresentation 两个函数协作完成。
{
return (interfaceOrientation != UIInterfaceOrientationMaskLandscapeLeft);
}-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight;
}-(BOOL)shouldAutorotate
{
return YES;
}5,6通吃。
CGAffineTransform transform = CGAffineTransformIdentity;
transform = CGAffineTransformRotate(transform, M_PI/2);
self.view.transform = transform;
注意此时视图横屏了但是状态栏还是纵屏显示的,所以需要修改状态栏方向(alertview的方向也会随之修改)
[[UIApplication sharedApplication]setStatusBar。。
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}-(BOOL)shouldAutorotate
{
return NO;
}-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
up
但-(BOOL)shouldAutorotate 这个方法 YES也可
[window addsubview:yourrootviewcontroller.view]
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
即可同理,如果是在某一个NavigationController里面,那么就设置这个NavigationController即可