相关疑难解决方法(0)

UIDeviceOrientationDidChangeNotification没有解雇?

我根本无法得到UIDeviceOrientationDidChangeNotification解雇.

我有我的AppDelegate,在这里我添加一个PolyOrientationViewController,它UInavigationController可以推动a VerticalNavigationController和a HorizontalViewController取决于iPad的方向.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    ISPolyOrientationTableViewController *pvc = [[ISPolyOrientationTableViewController alloc] init];
    [window addSubview:pvc.view];
    [pvc release];
    [window makeKeyAndVisible];

    return YES;
}
Run Code Online (Sandbox Code Playgroud)

Poly,Vertical和Horizo​​ntal viewController实现:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

PolyVC,它是最顶级的ViewController,它有以下方法:

- (void)viewDidLoad {

    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) 
                                                 name:UIDeviceOrientationDidChangeNotification
                                               object:nil];

    [super viewDidLoad];
}
Run Code Online (Sandbox Code Playgroud)

它有相关的功能:

- (void)didRotate:(NSNotification *)notification {
    //push the related controller
}
Run Code Online (Sandbox Code Playgroud)

在PolyVC的实例化之后,调用该didRotate:方法,从这里开始它只是停止生成UIDeviceOrientationDidChangeNotification,我想.

我在didRotate:方法中有一个断点,我已经将应用程序加载到iPad上以确保它不是模拟器的东西,我已经制作了一个新的xcode splitViewController项目,测试了旋转工作,删除了代码并粘贴了我自己的,我有检查了方向锁定按钮,我已经尝试实现-(BOOL) ShouldAutoRotate…我既没有被调用,我检查了info.plist指定应用程序支持所有方向,我已经尝试从我发现的工作示例中复制粘贴每一段通知代码打破错别字.

我完全在我的智慧结束:)这有什么我可以做的,一些实现UIViewController的方式,不使用IB,在ViewControllers中嵌套ViewControllers(PolyViewController拥有拥有Vertical和Horizo​​ntalViewController的UINavigationController)或任何将使应用程序完全忽略interfaceOrientation通知? …

ipad

2
推荐指数
2
解决办法
6818
查看次数

标签 统计

ipad ×1