开发者

ApplicationWillEnterForeground's inconsistent behaviour

I have password authentication for my application. My application is window based. I have five view: MyApplicationAppDelegate,MainViewController, HelpViewController, SettingViewController and ErrorViewController.

When the application starts, I na开发者_Python百科vigate to MainViewController. I have two buttons on toolbar for Help and Setting which direct to respective pages. Now, I have written following code in MyApplicationAppDelegate:

- (void)applicationWillEnterForegroundUIApplication *)application {

[self showMyView];

}


-(void)showMyView{
if (![Global timeSet]) {


if (errorviewFlag) {
if (![Global show]){
ErrorPageViewController *bViewController = [[[ErrorPageViewController alloc]
initWithNibName"ErrorPageViewController" bundle:[NSBundle mainBundle]] autorelease];

[self setError:bViewController];
self.error = bViewController;
//[window addSubview:[error view]];

[[self navigationController] pushViewController:bViewController animated: NO];
UIBarButtonItem *_backButton = [[UIBarButtonItem alloc] initWithTitle"Back" style:UIBarButtonItemStyleDone target:nil action:nil];
[self.navigationController setNavigationBarHidden:YES]; 
[self.navigationController setToolbarHidden:YES];

[_backButton release], _backButton = nil;
[window makeKeyAndVisible];
errorviewFlag=FALSE;
[Global setShow:TRUE];
}
}
}
}

Now, this method is called for all times except the first.

The problem is this only works in desired way, i.e. shows ErrorPage, when I minimize the application from MainView. If I minimize from Help or setting, it does not show the error page, but instead the mainpage with no navigation controls. Why?


He was able to find the answer. I used NSNotificationcenter with didEnterBackground. I used this in all other view than MainView. And in my didEnterBackground method i used [self.navigationController popViewControllerAnimated:NO];

This forced all other view to come to MainView when application is minised and this solved the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜