代码之家  ›  专栏  ›  技术社区  ›  Chandan Shetty SP

Ipad设备定位问题

  •  1
  • Chandan Shetty SP  · 技术社区  · 14 年前

    使用MailmFotalController子类MailmFotalController(MailmFotalController)显示MailmFotalController

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

    但在我的UIViewController类中,我有一个overhide shouldAutorotateToInterfaceOrientation as(这是我的项目需要)

        - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
        {
    return NO;
        }
    

    在展示我的mailcontroller后,如果我旋转设备,它在iPhone中会像预期的那样完美工作(支持景观左/右方向)。。。但同样的代码在iPad上不起作用。我是不是搞错了?是苹果虫吗?

    我正在使用这个api进行演示 [myViewController presentModalViewController:mailController animated:YES ];

    我在iPhone和iPad的视图控制器上都收到了这个警告 <UINavigationController: 0x7720920> returned NO from -shouldAutorotateToInterfaceOrientation: for all interface orientations. It should support at least one orientation.

    谢谢

    3 回复  |  直到 14 年前
        1
  •  5
  •   Philippe Leybaert    14 年前

    你实际上说的是“我不支持任何方向”,这当然是。。。不是真的。

    对于至少一个方向,应该返回true。例如:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
    {
       return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    
        2
  •  0
  •   Luke Mcneice    14 年前

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
    }
    
        3
  •  -2
  •   Underdog    13 年前
    MFMailComposeViewController *picker=[[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;
    [picker setSubject:self.title];
    [picker setMessageBody:body isHTML:YES];
    [picker shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft];
    [picker shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight];
    [picker shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait];
    [picker shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortraitUpsideDown];
    [self  presentModalViewController:picker animated:YES];
    

    这应该可以解决。。。