dismissModalViewController隐藏状态栏后面的父视图 [英] dismissModalViewController Hides the parent view behind status bar
问题描述
我这里有一个非常奇怪的问题。我正在使用一个现有的模态视图控制器来在ViewController上显示我的MFMailComposer ViewController,它放在导航栏中。
I have a very strange issue here. I am using a present modal view controller to display my MFMailComposer ViewController on top of a ViewController which is placed with in a Navigation Bar.
[self presentModalViewController:emailviewController animated:YES];
要隐藏,我使用...
to hide , I use ...
-(void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
[self dismissModalViewControllerAnimated:YES];
}
一切正常但当我解雇我的MailComposer时,原始视图控制器隐藏在状态栏 。
Everything works fine but when I dismiss my MailComposer the original view controller hides behind the status bar .
我尝试使用setFrame方法将视图偏移量修改为10,但它无法正常工作。 (这在模态视图控制器出现和解除之前和之后都很累)
I have tried to modify view offset by 10 using setFrame method but It din't worked . (this is tired before and after the modal view controller is presented and dismissed )
我试过暂时隐藏状态栏但没有工作。
I have tried by hiding status bar temporarily but didn't worked.
我已经尝试过self.navigationcontroller presentmodalviewcontrolle但是也没有用...
I have tried self.navigationcontroller presentmodalviewcontrolle but that didn't worked too...
任何想法或建议都将受到高度赞赏
Any ideas or suggestions would be highly appreciated
编辑:大多数人都给我一个手动修改偏移量的建议。
好吧,这不起作用。因为如果我在原始viewcontroller方法的viewDidLoad / viewWillapper中执行此操作,那么它会在当前模态视图控制器之前移动我的视图,而在我加载模态视图控制器之后它变得正常。
edited : Most of the people give me a suggestion to modify the offset manually. Well that does not work . Because if I do that in my viewDidLoad/viewWillapper of the original viewcontroller method then It shifts my view before the present modal view controller whereas after I load the modal view controller It becomes normal.
- (void)viewDidAppear:(BOOL)animated {
CGRect frame = self.navigationController.view.frame;
frame.origin.y = 20;
self.navigationController.view.frame = frame;
}
推荐答案
尝试将其放入ViewDidAppear:
Try putting this in ViewDidAppear:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
最糟糕的情况是,如果只在模态视图控制器被解除后才发生,则声明一个布尔值在.h中的afterFirstLaunch并将其放入viewDidAppear:
Worst case, if it is always happening only after the modal view controller is dismissed, declare a boolean for afterFirstLaunch in the .h and put this in viewDidAppear:
if(afterFirstLaunch){
CGRect frame = self.navigationController.view.frame;
frame.origin.y = 20;
self.navigationController.view.frame = frame;
}
else {
afterFirstLaunch = true;
}
这篇关于dismissModalViewController隐藏状态栏后面的父视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!