快速的应用程序切换,我需要什么?
我的应用程序在没有多任务处理支持的情况下也能正常工作。 但是当我在 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_... 在我创建开关的视图中? ??但前提是我之前点击了主页按钮! 如果我只推动视图然后返回。单击主页按钮。点击应用程序符号。然后尝试再次推送相同的视图,它会崩溃。 但是当我推动视图,返回并推动视图时,它就起作用了。当我在 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;
}
My App works fine without the multitasking support.
But when I activate it in the info.plist, then it crashes every time I pushed something on the navigationController and hit the home button, came back to the app and used the navigationController again.
The error message doesn't help me either.
What do I need to do for multitasking support in my app, when I only want the app to do nothing in the background and come back were it was.
Sadly instruments doesn't work correct either since Xcode 4.1 -_-".
The error-message in the console is sometimes:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CAContextImpl _isCached]: unrecognized selector sent to instance 0x5b783d0'
Sometimes it is an EXC_BAD_... in the view where I create a switch??? But only if I clicked the home button before!
If I only push the view and then go back. Click Home-Buttom. Tap App-Symbol. And then try to push the same view again it crashes.
But when I push the view, go back and push the view, it works. It only crashes, when I was in the SpringBoard (clicked the home Button).
Edit:
//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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从您的描述来看,多任务处理似乎不是问题所在。这听起来就像你的应用程序有一个错误。您应该尝试找出并修复它。
默认情况下,您的应用程序在后台不执行任何操作。
From your description, it does not appear that multitasking is the problem. This reads like your app has a bug. You should try to track that down and fix it.
By default, your app does nothing in the background.