我在我的UIViewController上使用presentModalViewController呈现MFMailComposeViewController(mailController),在mailController(MFMailComposeViewController的子类)类中,我已将overAutorotateToInterfaceOrientation隐藏为
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
但是在我的UIViewController类中,我已经过度隐藏了shouldAutorotateToInterfaceOrientation(这是我的项目需要)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return NO;
}
在展示我的邮件控制器之后,如果我旋转设备,它在iPhone中完全按预期工作(支持landscapeleft / right orientation)......但是相同的代码在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.
谢谢,
答案 0 :(得分:5)
你实际上说的是“我不支持任何方向”,这当然......不是真的。
您应该至少在一个方向返回true。例如:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
答案 1 :(得分:0)
此方法将同时允许横向:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
答案 2 :(得分:-2)
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];
这应该解决这个问题......