【发布时间】:2014-08-31 19:23:13
【问题描述】:
我有一个关于标题中提到的方法的快速实施的问题。如果我这样做:
leadingSpaceConstraint.constant = 0
UIView.animateWithDuration(0.3, animations: {
self.view.layoutIfNeeded()
}, completion: { (complete: Bool) in
self.navigationController.returnToRootViewController(true)
})
我遇到以下问题:调用中缺少参数“延迟”的参数。只有当我在完成部分有 self.navigationController.returnToRootViewController() 时才会发生这种情况。如果我将该语句提取到这样的单独方法中:
leadingSpaceConstraint.constant = 0
UIView.animateWithDuration(0.3, animations: {
self.view.layoutIfNeeded()
}, completion: { (complete: Bool) in
self.returnToRootViewController()
})
func returnToRootViewController() {
navigationController.popToRootViewControllerAnimated(true)
}
然后它完美地工作并且完全符合我的要求。当然,这似乎不是理想的解决方案,更像是一种解决方法。谁能告诉我我做错了什么或者为什么 Xcode(beta 6)会这样?
【问题讨论】:
-
长期以来,这一直是一个常见的问题原因。它总是以不同的方式表现出来......在这里查看答案:stackoverflow.com/questions/24338842/…
-
哈。我知道这已经被回答过,但没有找到骗子。 (实际上,我很确定在那个骗局之前我已经回答过了,但我在我的历史中也找不到它。)
-
尝试将
(complete:Bool) in更改为(complete:Bool) -> Void in
标签: ios swift xcode uiviewanimation