简体   繁体   English

如何将 self 作为委托从 tabViewController 中的一个 viewController 发送到另一个 viewController

[英]How do I send self as a delegate from one viewController in a tabViewController to another viewController

I have a custom tabViewController and I would like to pass self as a delegate from viewController one to viewController two (which is modal).我有一个自定义tabViewController ,我想将self作为delegateviewController一传递到viewController二(这是模态的)。 The problem is that when I go between viewControllers using the tabs the prepare function isn't triggered as the tabViewController handle the transitions I suppose.问题是,当我在 viewControllers 之间使用tabs viewControllers时, prepare function 不会被触发,因为tabViewController处理了我想的转换。

So how do I make this happen?那么我该如何实现呢? How do I pass self from one viewController to the next.如何将self从一个viewController传递到下一个。

Actually inside any VC that's inside the tab you could do实际上,在选项卡内的任何 VC 中,您都可以执行

// suppose you need to access second tab 
if let targetVC = self.tabBarController?.viewControllers[1] as? SecondVC {
  // do what you want
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用 mapKit 将坐标从 ViewController 发送到另一个具有委托的 viewController - Unable to send coordinates from ViewController with mapKit to another viewController with delegate 如何将字符串发送到另一个ViewController - How do I send strings to another viewcontroller 如何在单击时从一个ViewController(包含一个自定义UIView)移动到另一个ViewController(包含一个UITableView)? - How do I move from one ViewController (containing a custom UIView) to another ViewController (containing a UITableView) on click? 我想从不同的viewController回到tabViewController的特定页面 - I want to go back to specific page of a tabViewController from different viewController 将字符串从viewController发送到另一个 - Send a string from a viewController to another one 如何将信息从一个视图控制器发送到另一个? (斯威夫特 - IOS) - How to send info from one viewcontroller to another? (Swift - IOS) 如何将数据从一个ViewController发送到另一个具有SWRevealViewController的视图 - how to send data from one ViewController to another which has SWRevealViewController 如何快速将图像从一个视图控制器传递到另一个视图控制器? - How to pass an image from one viewcontroller to another viewcontroller in swift? 如何从另一个ViewController更改一个ViewController上的标签文本 - How to change a label text on one ViewController from another ViewController 如何在另一个ViewController之上显示一个ViewController? - How can I present one ViewController on top of another ViewController?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM