ios - 如何在另一个选项卡中向 View Controller 发送消息

标签 ios ipad

我为我的 iPad 应用程序使用 UiTabBarController。其中一个选项卡是带有收藏夹的 UITableView。当我单击一个单元格时,我希望收藏夹在另一个选项卡的 viewController 中打开。

我通过在单例中分配一个变量然后通过 [self.tabBarController setSelectedIndex:2] 选择另一个选项卡以丑陋的方式解决了它;

在目标 viewController 上的 ViewWillAppear 中,我从单例中读取值,然后执行所有操作。

必须有适当的方法来做到这一点。如何在另一个选项卡中引用 ViewController 的实例?有没有办法在选项卡中加载另一个 View Controller ?

任何人?

最佳答案

您可以使用 viewControllers 属性获取 Tab View 中的所有 View Controller 。

从文档:

The default value of this property is nil. When configuring a tab bar controller, you can use this property to specify the content for each tab of the tab bar interface. The order of the view controllers in the array corresponds to the display order in the tab bar. Thus, the controller at index 0 corresponds to the left-most tab, the controller at index 1 the next tab to the right, and so on. If there are more view controllers than can fit in the tab bar, view controllers at the end of the array are managed by the More navigation controller, which is itself not included in this array.

关于ios - 如何在另一个选项卡中向 View Controller 发送消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7619456/

相关文章:

iOS Swift JSON 检索数据问题

objective-c - 使用 ALAssetsLibrary 访问裁剪或编辑的图像

objective-c - 如何暂时隐藏 UIPopoverController

ios - 使用 CFTreeContext 信息对象将 NSString 数据存储在 CFTreeRef 中是一种好习惯吗

ios - 如何禁用 iPhone 和 iPad 设备的旋转动画

ios - 自定义选项卡栏以在 View Controller 之间导航

ios - SKEmitterNode的粒子生命周期到底是什么?

ios - 使用 NSAttributedString 更改字符串颜色?

ios - UICollectionView - 在横向模式下重新设计

iphone - 如何在 iOS 5 中访问标签栏 Controller ?