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.
我建议您不要重载整个根VC,而要单独设置数据类,可以根据需要进行重置-毕竟,VC实际上是用于显示所有内容。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.