iphone - popViewController iphone

标签 iphone objective-c ios uinavigationcontroller

我可以在不使用这样的代码的情况下从导航 Controller 堆栈中删除 View Controller 吗

[mynavigationController popViewControllerAnimated:YES];

我们将不胜感激。

最佳答案

@rishi 几乎做到了。您需要一个可变数组来进行编辑

NSMutableArray *activeControllerArray = 
    [self.navigationController.viewControllers mutableCopy];

[activeControllerArray removeObjectAtIndex:indexToRemove];
// If you still have a handle to the viewcontroller you could use other methods like removeObject:

self.navigationController.viewControllers = activeControllerArray;

片段来自 UINavigationController docs

@property(nonatomic, copy) NSArray *viewControllers

... Assigning a new array of view controllers to this property is equivalent to calling the setViewControllers:animated: method with the animated parameter set to NO.

关于iphone - popViewController iphone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8635107/

相关文章:

iPhone模拟器无法连接互联网

iphone - NavigationController背景图像问题

iphone - UITextField 的子类

iphone - IOS CS193p - 为什么 IBAction 连接被拖到 .m 文件而不是 .h?

ios - UITableView:单击单元格并使用 UIWebView 打开单元格中的链接

ios - 通过 Interface Builder 为所有 View Controller 设置默认全局背景颜色

ios - 空指针的取消引用

iphone - iPhone URL 方案的 Twitter 官方列表在哪里?

ios - 用于 webView 的 scalesPageToFit 不适用于 iOS 9.3

ios - 滑动时更改 UIslider 缩略图