有这一段代码:
MyViewController *_main = [[[MyViewController alloc] init]autorelease];
_navController = [[UINavigationController alloc] initWithRootViewController:_main];MyViewController的Class类里面重写了shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation实现了横屏不能竖屏,
MyViewController的xib文件里面,orientation属性设置横向。现在问题是我通过上面代码放到一个UINavigationController 内,运行结果是UINavigationController是竖屏的,而MyViewController是横屏的,而且不能旋屏了。我把MyViewController的xib文件里面,orientation属性设置为默认值后,也把shouldAutorotateToInterfaceOrientation注释掉,还是出现那个情况,不能旋屏;但如果我吧_navController = [[UINavigationController alloc] initWithRootViewController:_main];这句注释掉,就可以了,但你这样我没了UINavigationController 了。求解决办法

解决方案 »

  1.   

    你是不是 想运行后开始只出现横屏  然后还能旋屏  ?
    如果这样的话  只在 ios sdk 里summary选项  中 supported Device Orientations 有四个显示屏的选项 
    把它只保留横屏就行不用 在MyViewController的Class类里面重写了shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
      

  2.   

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        // Return YES for supported orientations
        return YES;
    }LZ给分。
      

  3.   

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation==UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation==UIInterfaceOrientationLandscapeRight);
        //return YES;
    }