ios - 显示 View 后立即添加 subview
<p><p>我有 2 个 ViewA 和 B。
在 ViewA </p>
<pre><code>presentViewController(viewB, animation: true) {
NSNotificationCenter.defautCenter.postNotificationName("addButton")
}
</code></pre>
<p>在 ViewB:
var masterView:UIView!</p>
<pre><code>func addButton(notification: NSNotification){
var button:UIButton!
button.frame = masterView.caculator // set frame for button
self.addSubview(button)
}
</code></pre>
<p>当 ViewB 在模拟器上完成动画时(从底部开始)。延迟 0.3 秒后添加的按钮。</p>
<p>跟随一些文档,当动画完成时,方法 viewDidAppear 被调用。我试过这种方式。但正如我所见,动画完成 0.3 秒后添加的按钮</p>
<p>如何在动画完成后立即添加按钮?
谢谢!</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我已经解决了。因为在<code>viewDidAppear</code>中,这个方法是在所有Layout加载完毕的时候调用的。
所以我们需要在 <code>LayoutSubview</code> 方法中实现 add my button。</p></p>
<p style="font-size: 20px;">关于ios - 显示 View 后立即添加 subview ,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/38711203/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/38711203/
</a>
</p>
页:
[1]