ViewControllerスタックから最上位レベルを削除
1572 ワード
if([delete_navigation.visibleViewController isKindOfClass:[TopicViewController class]] && [topicNotification.topic.id isEqualToString:self.otherTopicID]){//
TopicViewController *controller=(TopicViewController *)delete_navigation.visibleViewController;
controller.topicNotification=topicNotification;
controller.topicId=topicNotification.topic.id;
[controller refreshTopic];
}else{
TopicViewController *controller= [[TopicViewController alloc] initWithNibName:@"TopicViewController" bundle:nil];
controller.topicNotification=topicNotification;
controller.topicId=topicNotification.topic.id;
if([delete_navigation.topViewController isKindOfClass:[TopicViewController class]]){
NSMutableArray *navigationArray = [[NSMutableArray alloc] initWithArray: delete_navigation.viewControllers];
// [navigationArray removeAllObjects]; // This is just for remove all view controller from navigation stack.
[navigationArray removeLastObject]; // You can pass your index here
delete_navigation.viewControllers = navigationArray;
}
[delete_navigation pushViewController:controller animated:YES];
}
これはプログラムコードです.自分の都合で削除して調整します.