
我正在使用在iOS8上运行的Swift编程解决方法 这适用于Swift 3和Swift 4.您可以在AppDelegate.swift中使用以下代码: @H_419_16@func application(_ application: UIApplication,supportedInterfaceOrIEntationsFor window: UIWindow?) -> UIInterfaceOrIEntationMask { guard let rootVIEwController = self.topVIEwControllerWithRootVIEwController(rootVIEwController: window?.rootVIEwController),(rootVIEwController.responds(to: Selector(("canRotate")))) else{ // Only allow portrait (standard behavIoUr) return .portrait; } // Unlock landscape vIEw orIEntations for this vIEw controller return .allButUpsIDeDown;}private func topVIEwControllerWithRootVIEwController(rootVIEwController: UIVIEwController!) -> UIVIEwController? { guard rootVIEwController != nil else { return nil } guard !(rootVIEwController.isKind(of: (UITabbarController).self)) else{ return topVIEwControllerWithRootVIEwController(rootVIEwController: (rootVIEwController as! UITabbarController).selectedVIEwController) } guard !(rootVIEwController.isKind(of:(UINavigationController).self)) else{ return topVIEwControllerWithRootVIEwController(rootVIEwController: (rootVIEwController as! UINavigationController).visibleVIEwController) } guard !(rootVIEwController.presentedVIEwController != nil) else{ return topVIEwControllerWithRootVIEwController(rootVIEwController: rootVIEwController.presentedVIEwController) } return rootVIEwController}
你可以在原帖中了解更多:http://www.jairobjunior.com/blog/2016/03/05/how-to-rotate-only-one-view-controller-to-landscape-in-ios-slash-swift/
总结以上是内存溢出为你收集整理的ios – 仅在一个ViewController中旋转全部内容,希望文章能够帮你解决ios – 仅在一个ViewController中旋转所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)