问题:我出现后,我的状态栏显示在navigationBar
之上,并将MFMailComposerViewController
视为模态视图。
-(IBAction)openMail:(id)sender
{
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:emailTitle];
[mc setMessageBody:messageBody isHTML:YES];
[mc setToRecipients:toRecipents];
[mc.navigationItem.leftBarButtonItem setTintColor:[UIColor colorWithRed:144/255.0f green:5/255.0f blue:5/255.0f alpha:1.0f]];
[self presentViewController:mc animated:YES completion:NULL];
}
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
switch (result)
{
case MFMailComposeResultCancelled:
NSLog(@"Mail cancelled");
break;
case MFMailComposeResultSaved:
NSLog(@"Mail saved");
break;
case MFMailComposeResultSent:
NSLog(@"Mail sent");
break;
case MFMailComposeResultFailed:
NSLog(@"Mail sent failure: %@", [error localizedDescription]);
break;
default:
break;
}
// Reset background image for navigation bars
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navigationBar.png"] forBarMetrics:UIBarMetricsDefault];
NSLog(@"%@",[GGStackPanel printFrameParams:self.view]);
// Close the Mail Interface
GGAppDelegate * appDel = [[UIApplication sharedApplication] delegate];
HHTabListController * contr = (HHTabListController*)appDel.viewController;
[contr setWantsFullScreenLayout:NO];
NSLog(@"%i",[contr wantsFullScreenLayout]);
[self dismissViewControllerAnimated:YES completion:NULL];
}
Stackoverflow上有几个类似的问题,但没有一个解决方案表明它对我有用。 我已经尝试过了:
status bar and Navigation bar problem after dismissed modal view
http://developer.appcelerator.com/question/120577/nav-bar-appears-underneath-status-bar
我尝试从AppDelegate提出并解雇,没有帮助。
更改视图框架或navigationBar框架是可行的,但我必须对我的应用程序中的所有其他视图执行相同的操作(其中有许多视图)。这将使我的整个应用程序依赖于这个小错误。
请不要低估这个问题,因为有类似的问题。我非常绝望,这个问题让我烦恼了3天。
View before presenting http://imageshack.us/a/img801/8946/beforet.png
解雇MailComposer后:
View after dismissing http://imageshack.us/a/img507/8940/afterb.png
答案 0 :(得分:3)
wantsFullScreenLayout是复杂且无关的东西。所有的viewcontrollers都需要嵌入到“layout”视图控制器(Apples UINavigationController,Apple的UITabBarController)中,或者完全实现“我应该有多大,我在哪里定位?”的复杂逻辑。自己。
Apple决定使用iOS 1.0,你看到的主要iPhone视图不会从0,0开始。包含它的窗口从(0,0)开始,但状态栏显示为OVERLAPPED。
我认为这是他们后悔的决定,当时有道理,但从长远来看,它会造成很多错误。
净效应是:
(代码)
UIViewController* rootController = // in this case HHTabController?
UIView* rootView = rootController.view;
CGRect frame = rootView.frame;
CGPoint oldOrigin = frame.origin;
CGPoint newOrigin = // calculate this, according to Apple docs.
// in your current case, it should be: CGPointMake( 0, 20 );
frame.origin = newOrigin;
frame.size = CGSizeMake( frame.size.width - (newOrigin.x - oldOrigin.x), frame.size.height - (newOrigin.y - oldOrigin.y) );
rootView.frame = frame;
......显然,每次都要这样做很烦人。这就是为什么Apple强烈鼓励大家使用UINavigationController和/或UITabBarController:)
答案 1 :(得分:0)