通知を使用して、詳細ビューコントローラからアプリケーションのrootviewcontrollerにデータを渡しています。メモリの警告があるまで、メソッドは正常に動作します。iPhone - メモリ警告後に通知が2回ポストされる
通知はメモリ警告の後に2回処理されます。
ユーザーがDetailViewControllerで行を選択すると、データをrootviewcontrollerに渡します。 didSelectRowAtIndexPathメソッドは1回だけ呼び出されますが、通知オブザーバは2回呼び出されます。
didReceiveMemoryWarningで通知を削除する必要がありますか?それともコードに何か他の問題がありますか?
関連するコードを投稿
RootViewControllerののviewDidLoad
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rowSelected:) name:@"SelectionNotification" object:nil];
任意の助けDetailViewControllerのdidSelectRowAtIndexPath
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSMutableDictionary *dictionary = [[[NSMutableDictionary alloc] init] autorelease];
[dictionary setObject:selectedRow forKey:@"row"];
[[NSNotificationCenter defaultCenter] postNotificationName:kSelectionNotificationName object:self userInfo:dictionary];
[[self navigationController] popToRootViewControllerAnimated:YES];
}
感謝。
あなたのビューは複数回ロードされアンロードされ、それに応じてコードされると仮定します。 –