I’m trying to make an iPhone app, but i found some issue that auto-rotate is not working after I reload the view controller.
here is the code for loading the app for first run:
//AppDelegate.m:<br />
-(BOOL) application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
iPhoneScanViewController = [[iPhoneScan alloc] init];
iPhoneScanViewController.ENAD = self;
[window addSubview:iPhoneScanViewController.view];
[self.window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
the view controller loads, autorotate is working.
then sometimes I need to reload the view controller, this is what I use:
-(void) resetIphoneScan {
if (iPhoneScanViewController) {
[iPhoneScanViewController release];
}
iPhoneScanViewController = [[iPhoneScan alloc] init];
iPhoneScanViewController.ENAD = self;
for (UIView *view in [window subviews])
{
[view removeFromSuperview];
}
[window addSubview:iPhoneScanViewController.view];
[self.window makeKeyAndVisible];
}
After I reload / resetIphoneScan, the autorotate won’t work. I’ve spend a few days on this problem and I haven’t found solution for that. I really appreciate any help.
Thanks in advance.
I would suggest that rather than reload the entire root VC, you have separate data classes which you can reset as necessary – after all, the VC is really for displaying it all.