たぶん、私はこれをあまりにも長い間見てきました;) 私のアプリには、NavigationController といくつかの ViewControllers があります。rootViewController からロードされた ViewControllers の 2 レベル下 (mainViewController) の 1 つから、以下のコードがあります。PushViewController から dataViewController に戻った後 (戻るボタンを押すなど)、アプリがクラッシュします。
dataViewController は正常にロードされますが、navigationController の戻るボタンがタップされると、アプリケーションは Object Exception でクラッシュします。私が削除した場合:
[dataViewController release];
アプリは正常に動作します。dataViewController が同じメソッドで初期化されているため、奇妙です。何か案は?
- (void) locationPage
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"NotifyRemoveMap" object:nil];
MyAppDelegate *app = [[UIApplication sharedApplication] delegate];
UINavigationController *navigation = app.navigationCantroller;
[navigation popToRootViewControllerAnimated:NO];
DataViewController *dataViewController = [[DataViewController alloc] initWithNibName:@"DataView" bundle:nil];
[dataViewController setCategoryId:category];
MyLanguage *lang = app.lang;
Mylocation *location = [lang locationForCategoryId:category];
dataViewController.title = location.name;
NSArray *locationArray = [lang locations];
dataViewController.locations = locationArray;
[navigation pushViewController:dataViewController animated:YES];
[dataViewController release]; // With this removed, app doesn't crash
}