ViewController 堆栈中移除最上层

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];
            
        }

 这是程序代码,要根据自己的情况 删除 调整

你可能感兴趣的:(controller)