当前位置:编程学习 > wap >>

如何只设置某个controller视图为横屏

要做视频播放的视图,要求横屏播放

可是我的整个应用是只支持竖屏

 ios5下在视频视图横屏用
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

可是ios6下横屏怎么写?

谢谢 --------------------编程问答-------------------- 木有回答的吗?????? --------------------编程问答-------------------- 如果是全部竖屏,就在plist里面设置,如果每个页面不一样,就在不同页面设置,ios6废弃了这个方法! --------------------编程问答-------------------- iOS6的话,文档里说明:shouldAutorotateToInterfaceOrientation:
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 两个函数协作完成。 --------------------编程问答--------------------
引用 3 楼 dream238 的回复:
iOS6的话,文档里说明:shouldAutorotateToInterfaceOrientation:
Returns a Boolean value indicating whether the view controller supports the specified orientation. (Deprecated in iOS 6.0. Override t……


有代码吗?

谢谢 --------------------编程问答-------------------- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationMaskLandscapeLeft);
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeRight;
}

-(BOOL)shouldAutorotate
{
    return YES;
}

5,6通吃。
--------------------编程问答-------------------- 最近很多人在问这个问题??

在相对应的视图控制器(ViewController.m)的viewDidLoad方法中加入下面代码
CGAffineTransform transform = CGAffineTransformIdentity;
    transform = CGAffineTransformRotate(transform, M_PI/2);
    self.view.transform = transform;
注意此时视图横屏了但是状态栏还是纵屏显示的,所以需要修改状态栏方向(alertview的方向也会随之修改)
[[UIApplication sharedApplication]setStatusBar。。。。。
--------------------编程问答-------------------- 这个问题我之前也有遇到,也是米为了播放视频,你试试 --------------------编程问答-------------------- 在view里重栽以下方法

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

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}
--------------------编程问答--------------------
引用 8 楼 wshcdr 的回复:
在view里重栽以下方法

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

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}


up
但-(BOOL)shouldAutorotate 这个方法 YES也可
--------------------编程问答-------------------- 首先,你得说明你的整个视图控制器的结构是怎么样的,在IOS6下,这个层次很重要,不然就算你的某个视图中加了那几个控制旋转的方法也起不了作用;你如果用了navigationcontroller,那么请在根navigationcontroller中填写控制旋转的方法就可以了,如果你其他视图要另外控制不同的旋转方向,就可以给再加一个navigationcontroller,旋转代码同理写在这个navigationcontroller中;这也就以为着你需要继承写navigationcontroller用来填写旋转方向的代码; --------------------编程问答-------------------- 还有一个比较关键的地方,在appdelegate中用window.rootViewController=yourrootviewcontroller替换原来ios5中的
[window addsubview:yourrootviewcontroller.view] --------------------编程问答-------------------- 能教教代码怎么写么?我也用了navigationcontroller,但是代码不知道怎么写呢,求大神救救小女子吧 --------------------编程问答-------------------- --------------------编程问答-------------------- iOS6的方法楼上面都有说明了,你要注意VC的结构。如果没有起到你要的效果,就是当前VC在当前Windows上还有父VC
补充:移动开发 ,  iPhone
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,