我的应用程序工作正常,没有多任务的支持。 但是,当我在info.plist中激活它时,每当我在navigationController上推动某些东西并点击home按钮时,它就会崩溃,回到应用程序并再次使用navigationController。 错误信息也不帮助我。快速切换应用程序,我需要什么?
当我只想让应用程序在背景中不执行任何操作并返回时,我需要为我的应用程序中的多任务支持做些什么。
可悲的是仪器不能正常工作正确要么因为Xcode的4.1 -_-”
错误消息在控制台有时是:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CAContextImpl _isCached]: unrecognized selector sent to instance 0x5b783d0'
有时它是一个EXC_BAD _... 在我创建开关的视图中 ???但是,只有当我点击主页按钮之前! 如果我只推动视图,然后回去。点击Home-Buttom。点击App-Symbol。然后尝试推动同样的看法,它再次崩溃 但是当我推视图,回去推视图,它窝RKS。当我在SpringBoard时,它只会崩溃(点击home按钮)。
编辑:
//AppDelegate class
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[window makeKeyAndVisible];
[self loadHauptmenu];
return YES;
}
- (void) loadHauptmenu {
NSLog(@"loading Hauptmenu");
navigationController = [[UINavigationController alloc] init];
HauptMenuViewController *hauptMenuController = [[HauptMenuViewController alloc] init];
[navigationController pushViewController:hauptMenuController animated:NO];
// [hauptMenuController release]; //tried this as error, but wasn't it
[window addSubview:navigationController.view];
}
//Main Menu class
- (void) pushNewViewController:(UIViewController*)pushMe {
NSLog(@"Der aktuelle navigationController ist: %@", self.navigationController);
[self.navigationController pushViewController:pushMe animated:YES];
}
- (void) pushNewViewWithClassname:(NSString*)classname {
UIViewController *viewControllerToPush = [[NSClassFromString(classname) alloc] init];
[self pushNewViewController:viewControllerToPush];
[viewControllerToPush release];
}
- (IBAction) pushEinstellungen:(id)sender {
[self pushNewViewWithClassname:@"EinstellungenViewController"];
}
//view class, which gets pushed
- (id) init {
self = [super init];
if (self != nil) {
self.title = @"Einstellungen";
//self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 416)];
self.view.backgroundColor = MEDILEARN_COLOR;
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 416) style:UITableViewStyleGrouped];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.allowsSelection = NO;
self.tableView.backgroundColor = [UIColor clearColor];
[self.view addSubview:self.tableView];
self.fragenSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(194, 8, 94, 28)]; //here is an EXC_BAD_...
[self.fragenSwitch addTarget:self action:@selector(toggleEnabledForFragenSwitch:) forControlEvents:UIControlEventValueChanged];
[self.fragenSwitch setOn:[[NSUserDefaults standardUserDefaults] boolForKey:@"randFragen"] animated:NO];
self.antwortenSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(194, 8, 94, 28)];
[self.antwortenSwitch addTarget:self action:@selector(toggleEnabledForAntwortenSwitch:) forControlEvents:UIControlEventValueChanged];
[self.antwortenSwitch setOn:[[NSUserDefaults standardUserDefaults] boolForKey:@"randAntworten"] animated:NO];
}
return self;
}
你不应该做任何事情。为了更好地利用多任务,您可以做些事情,但即时可用的iOS应该能够将您的应用恢复到切换时的状态。 – Jason