
我在每个视图中使用这些行:
- (BOol)shouldautorotate{ return YES;}- (NSUInteger)supportedInterfaceOrIEntations{ if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { return UIInterfaceOrIEntationMaskPortrait; } else { return UIInterfaceOrIEntationMaskAll; }}- (UIInterfaceOrIEntation)preferredInterfaceOrIEntationForPresentation{ return UIInterfaceOrIEntationPortrait;} 它几乎可以在使用UINavigationController的视图中工作,但是在使用UITabbarController的视图中我遇到了很大的问题,因为它接缝代码没有被调用.
解决方法 好吧我解决了,你必须继承UINavigationController和UITabbarController,所以这里是代码://cCustomNavigationController.h file#import <UIKit/UIKit.h>@interface cCustomNavigationController : UINavigationController <UINavigationControllerDelegate>@end//cCustomNavigationController.m file#import "cCustomNavigationController.h"@interface cCustomNavigationController ()@end@implementation cCustomNavigationController - (BOol)shouldautorotate { return [self.visibleVIEwController shouldautorotate];}- (NSUInteger)supportedInterfaceOrIEntations { return [self.visibleVIEwController supportedInterfaceOrIEntations];}- (UIInterfaceOrIEntation)preferredInterfaceOrIEntationForPresentation { return [self.visibleVIEwController preferredInterfaceOrIEntationForPresentation];}@end//cCustomTabController.h file#import <UIKit/UIKit.h>@interface cCustomTabController : UITabbarController <UITabbarControllerDelegate>@end//cCustomTabController.m file#import "cCustomTabController.h"@interface cCustomTabController ()@end@implementation cCustomTabController- (BOol)shouldautorotate { return [self.selectedVIEwController shouldautorotate];}- (NSUInteger)supportedInterfaceOrIEntations { return [self.selectedVIEwController supportedInterfaceOrIEntations];}- (UIInterfaceOrIEntation)preferredInterfaceOrIEntationForPresentation { return [self.selectedVIEwController preferredInterfaceOrIEntationForPresentation];}@end 现在你只需要在你需要它的地方创建你的TabbarController或者你的NavigationController,即
//For the UINavigationControllerUINavigationController *navigationController = [[cCustomNavigationController alloc] init];//For the UITabbarControllerUITabbarController *tabController = [[cCustomTabController alloc] init];
我希望这能帮到你们.
总结以上是内存溢出为你收集整理的uinavigationcontroller – shouldAutorotate,supportedInterfaceOrientations和preferredInterfaceOrientationForPresentation在iOS 7中无法正常工作全部内容,希望文章能够帮你解决uinavigationcontroller – shouldAutorotate,supportedInterfaceOrientations和preferredInterfaceOrientationForPresentation在iOS 7中无法正常工作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)