Cut*_*are 1 iphone xcode objective-c ios8
我已经尝试这样做了两个星期,并且发现它不起作用的原因:
弃用的API
不推荐使用以下API:
UIViewController接口方向的方法和属性.如统一故事板中的通用应用程序所述,特征和大小类会替换它们.
我需要的是:a FirstViewController,这是rootViewController我的navigationController.本FristViewController应只在人像模式(不是永远永远永远显示在景观)可用.
然后在导航堆栈中有一些中间ViewControllers(支持两种方向),直到我到达a LastViewController,这应该仅在LandscapeRight模式下可用(并且永远不会在纵向或其他模式下).
我一直在尝试使用以下内容CustomNavigationController,但显然iOS8中的内容发生了变化,我无法让它工作:
- (BOOL)shouldAutorotate { // Available in iOS 6.0 and later
return YES; // // May use topViewController's, but in this app it always returns YES
}
- (NSUInteger)supportedInterfaceOrientations { // Available in iOS 6.0 and later
if (self.topViewController != nil)
return [self.topViewController supportedInterfaceOrientations];
else
return [super supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { // Available in iOS 6.0 and later
if (self.topViewController != nil)
return [self.topViewController preferredInterfaceOrientationForPresentation];
else
return [super preferredInterfaceOrientationForPresentation];
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
您遇到的问题与iOS 8无关.以下是一些注意事项:
你误解了关于什么被弃用的说明.只有名称之类的willRotate方法已弃用,并且您还没有使用它们.
在supportedInterfaceOrientations工作方面没有任何改变.但是,请确保使用beta 4进行测试,因为测试版1-3中存在一个错误,导致视图控制器方向无法正常工作.
"然后导航堆栈中有一些中间ViewControllers(支持两种方向),直到我到达一个LastViewController,它应该只在LandscapeRight中可用"......这是不可能的,但不是因为iOS 8.你是什么描述自iOS 6以来一直是非法的!你不能有一个导航堆栈不同的视图控制器不同的强迫方向.只有呈现的视图控制器才能强制旋转(正如我在此处和许多其他答案中所解释的那样:https://stackoverflow.com/a/21616025/341994).
| 归档时间: |
|
| 查看次数: |
9565 次 |
| 最近记录: |