A second viewcontroller has mailcontroller and after finishing mail, it post a message to the mainviewcontroller to remove the secondviewcontroller's view. but it's not happening. The mailcontroller appearing and disappearing seem to interferes with finish function of the mainviewcontroller.
secondviewcontr开发者_如何学Gooller:
[self dismissModalViewControllerAnimated:YES];
[[NSNotificationCenter defaultCenter] postNotificationName:@"finish" object:nil];
mainviewcontroller:
-(void) finish:(NSNotification *)notif {
[MyviewController.view removeFromSuperview];
}
The removal of the second view controller should be delayed until your modal controller is really removed. What I have done is following:
[self dismissModalViewControllerAnimated:YES];
m_shouldHide = YES;
And then:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if ( m_shouldHide )
{
[self dismissModalViewControllerAnimated:YES];
m_shouldHide = NO;
}
}
精彩评论