![](/img/trans.png)
[英]How to reloadData() in ViewController #1 after ViewController #2 is dismissed?
[英]Segue not running after MPC viewcontroller is dismissed
我有一个动作可以弹出MPC视图控制器,但是一旦执行了该操作并且浏览器被关闭,我将直接回到我的旧视图控制器
func browserViewControllerDidFinish(
browserViewController: MCBrowserViewController!) {
// Called when the browser view controller is dismissed (ie the Done
// button was tapped)
func seguetoJoin(segue: UIStoryboardSegue, sender: AnyObject?) {
var joinView: playMusicViewController = segue.destinationViewController as! playMusicViewController
weak var delegate: MCBrowserViewControllerDelegate!
}
self.dismissViewControllerAnimated(true, completion: nil)
}
您似乎在正在接收didFinish回调的VC上调用dismissViewController。
您应该将安全代码移至需要执行安全代码的ViewController上,而不是在正在被关闭的ViewController上执行。
而且这些都没用
var joinView: playMusicViewController = segue.destinationViewController as! playMusicViewController
weak var delegate: MCBrowserViewControllerDelegate!
更新-
在下面的评论。
在mpcSubClass.m中var viewControllerToPeformSegue:UIViewController!
func browserViewControllerDidFinish(browserViewController: MCBrowserViewController!) {
// animation:false as your segue will have an animation
self.dismissViewControllerAnimated(false, completion: nil)
self.viewControllerToPerformSegue.handleBrowserDidFinish()
}
在viewControllerToPerformSegue.m中
// when you initialise the MPC VC subclass
mpcVCSubclass.viewControllerToPerformSegue = self
func handleBrowserDidFinish()
{
self.performSegueWithIdentifier("mainViewSegue", sender: self)
}
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!)
{
if segue.identifier == "mainViewSegue"
{
let mainVC = segue.destination as! MainVC
// now pass any data to your main VC that it can load in viewWillAppear
}
}
在故事板中
将viewControllerToPerformSegue链接到MainVC并将名称命名为mainViewSegue
希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.