大佬教程收集整理的这篇文章主要介绍了iphone – xcode – 如何将视图锁定为纵向模式,但仍允许一个视图旋转?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { return UIInterfaceOrientationMaskPorTrait | UIInterfaceOrientationMaskPorTraitUpsideDown; }
除了一个屏幕外,无论设备如何旋转,如何将视图锁定为纵向模式?
-(NSInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeLeft; }
**来自所有其他视图的方法,当我不希望它们旋转时,这些视图会旋转出来
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // IOS5 Only returning that it should rotate to poTrait return (interfaceOrientation == UIDeviceOrientationPorTrait); } -(BOOL)shouldAutorotate { // forcing the rotate IOS6 Only return YES; } -(NSInteger)supportedInterfaceOrientations { // return number or enum IOS6 Only return UIInterfaceOrientationMaskPorTrait; }
我想也许可能是因为UITabBarController是根控制器而我在ViewController中呢?这些方法甚至没有开火?
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NsnotificationCenter defaultCenter] addObserver:self SELEctor:@SELEctor(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:[UIDevice currentDevice]];
然后根据orientationChanged方法中的横向视图设置视图,如下所示:
- (void) orientationChanged:(Nsnotification *)note{ UIDevice * device = [UIDevice currentDevice]; switch(device.orientation) { case UIDeviceOrientationPorTrait: break; case UIDeviceOrientationPorTraitUpsideDown: break; case UIDeviceOrientationLandscapeLeft: break; case UIDeviceOrientationLandscapeRight: break; default: break; }; }
以上是大佬教程为你收集整理的iphone – xcode – 如何将视图锁定为纵向模式,但仍允许一个视图旋转?全部内容,希望文章能够帮你解决iphone – xcode – 如何将视图锁定为纵向模式,但仍允许一个视图旋转?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。