概要として、ビューがスタックからポップされるたびに viewWillAppear を呼び出す UITabBarController 内の UINavigationController に問題があります。
デリゲートから、UITabBarController がプログラムで作成されます。
// Create views for Tab Bar
UINavigationController *view1 = [[UINavigationController alloc] initWithRootViewController:[[newsFeedNavigationController alloc] initWithStyle:UITableViewStylePlain]];
resizedTabBatItem *tabBarItem1 = [[resizedTabBatItem alloc] initWithTitle:nil image:[UIImage imageNamed:@"newspaper.png"] tag:0];
[view1 setTabBarItem:tabBarItem1];
[tabBarItem1 release];
UIViewController *view2 = [UIViewController new];
resizedTabBatItem *tabBarItem2 = [[resizedTabBatItem alloc] initWithTitle:nil image:[UIImage imageNamed:@"speechbubble.png"] tag:1];
[view2 setTabBarItem:tabBarItem2];
[tabBarItem2 release];
....
// Create the tab bar controller
bookTabBarController = [BookTabBarController new];
[[bookTabBarController view] setFrame:CGRectMake(0, 0, 320, 460)];
// Add the views to it
NSArray *viewControllers = [NSArray arrayWithObjects:view1, view2, view3, view4, view5, nil];
[[bookTabBarController tabBarController] setViewControllers:viewControllers];
私の newsFeedNavigationController は単なるサブクラス化された UITableViewController です (サブクラスは、newsFeedNavigationController で呼び出されることはないため、viewWillAppear に干渉していません)。その中で、クリックすると新しい UIViewController をスタックにプッシュするアイテム。
問題は、ビューがスタックからポップされるたびに、newsFeedNavigationController で viewWillAppear が呼び出されず、リスト内の項目が強調表示されたままになることです。私はこれを数時間いじっていましたが、何が間違っているのかを知るために助けが必要なところです。
私の newsFeedNavigationController で、NSLog を追加して、それが呼び出されたかどうか、または何かを実行したかどうかを確認しようとしましたが、呼び出されることさえありません。
- (void)viewWillAppear:(BOOL)animated {
NSLog(@"is viewWillAppear called?");
[super viewWillAppear:animated];
}
編集:
さて、ここで私が気づいた奇妙なことがあります:
私が実行した場合:
[self presentModalViewController:(any UIview) animated:YES];
ビューをポップしてプッシュすると、viewWillAppearが適切に機能し始めます...だから今、私は困惑しています。それは実際には解決策ではありませんが、進行中の何かの内部である可能性があります。