I am trying to get my iPhone app to restart programmatically when the Logout button is pressed.
Has anyone got a code sample to share? I\'ve read that it is possible
try this, it works for me.
-(void)restart
{
MyAppDelegate *appDelegate = (MyAppDelegate *)([UIApplication sharedApplication].delegate);
[appDelegate.navigationController popToRootViewControllerAnimated:NO];
UIViewController *topViewController = appDelegate.navigationController.topViewController;
Class class = [topViewController class];
NSString *nibName = topViewController.nibName;
UIViewController *rootViewcontroller = (UIViewController *)([[class alloc] initWithNibName:nibName bundle:nil]);
[appDelegate.navigationController.view removeFromSuperview];
appDelegate.navigationController.viewControllers = [NSArray arrayWithObject:rootViewcontroller];
[appDelegate.window addSubview:appDelegate.navigationController.view];
[appDelegate.window makeKeyAndVisible];
}