私のアプリは、マルチタスクのサポートがなくても正常に動作します。しかし、info.plistでアクティブにすると、navigationControllerで何かを押してホームボタンを押し、アプリに戻って、navigationControllerを再度使用するたびにクラッシュします。エラーメッセージも役に立ちません。
アプリでバックグラウンドで何も実行せず、元の状態に戻ってほしい場合に、アプリでマルチタスクサポートを行うために何をする必要がありますか。
悲しいことに、Xcode 4.1 -_- "以降、楽器も正しく機能しません。
コンソールのエラーメッセージは次のとおりです。
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CAContextImpl _isCached]: unrecognized selector sent to instance 0x5b783d0'
時々それは私がスイッチを作成するビューでEXC_BAD_...です??? ただし、前にホームボタンをクリックした場合のみです。ビューを押してから戻るだけの場合。[ホーム]-[下]をクリックします。App-Symbolをタップします。次に、同じビューをもう一度プッシュしようとすると、クラッシュします。しかし、ビューを押して戻ってビューを押すと、機能します。SpringBoardにいるとき(ホームボタンをクリックしたとき)にのみクラッシュします。
編集:
//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;
}