2016-08-02 173 views
2

我有两个视图A和B. 在视图中的添加子视图后视图呈现

presentViewController(viewB, animation: true) { 
    NSNotificationCenter.defautCenter.postNotificationName("addButton") 
} 

在视图B: VAR马西德威:UIView的!

func addButton(notification: NSNotification){ 
    var button:UIButton! 
    button.frame = masterView.caculator // set frame for button 
    self.addSubview(button) 
} 

在模拟器上查看B完成的动画(从底部开始)。延迟0.3秒后添加按钮。

以下一些文档,当动画完成时,方法viewDidAppear调用。我试过这种方式。但正如我所看到的,动画完成后添加了按钮0.3s

如何在动画完成时立即添加按钮? 谢谢!

+0

为什么你不在xib或storyboard中添加 –

+0

@MikeAlter,因为我在每个viewController中使用masterView大小是动态的 –

回答

0

我已经解决了。因为在viewDidAppear中,当所有布局加载时调用此方法。 所以我们需要在LayoutSubview方法中添加我的按钮。

相关问题