[英]How can I perform an embed segue twice?
I have a containerView with an embedded viewController. 我有一个带有嵌入式viewController的containerView。 Sometimes I need to perform the embed segue again with different sender but I'll get this error:
有时我需要与其他发送者再次执行embed segue,但会收到此错误消息:
'There are unexpected subviews in the container view. '容器视图中有意外的子视图。 Perhaps the embed segue has already fired once or a subview was added programmatically?'
也许嵌入脚本已经被触发一次,或者以编程方式添加了子视图?
Is it possible to to perform a embed segue multiple times or not?! 是否可以多次执行嵌入Segue?
You just need to make sure to programmatically cleanup the previously embedded view controller as described in the second part of https://stackoverflow.com/a/32166435/1049134 : 您只需要确保按照https://stackoverflow.com/a/32166435/1049134第二部分中所述的方式,以编程方式清理先前嵌入的视图控制器:
[self.containedViewController willMoveToParentViewController:nil];
self.containedViewController.view removeFromSuperView];
[self.containedViewController removeFromParentViewController];
The next time you trigger your embed segue it will work just like it did the first time. 下次触发嵌入序列时,它将像第一次一样起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.