相关疑难解决方法(0)

嵌套闭包不喜欢参数列表

UIView需要根据自定义控件的完成处理程序更改警告标签:

    voucherInputView.completionHandler = {[weak self] (success: Bool) -> Void in

        self?.proceedButton.enabled = success
        self?.warningLabel.alpha = 1.0

        if success
        {
            self?.warningLabel.text = "Code you entered is correct"
            self?.warningLabel.backgroundColor = UIColor.greenColor()
        }
        else
        {
            self?.warningLabel.text = "Code you entered is incorrect"
            self?.warningLabel.backgroundColor = UIColor.orangeColor()
        }


        UIView.animateWithDuration(NSTimeInterval(1.0), animations:{ ()-> Void in
            self?.warningLabel.alpha = 1.0
        })
Run Code Online (Sandbox Code Playgroud)

最终动画块在表单中显示错误.

Cannot invoke 'animateWithDuration' with an argument list of type '(NSTimeInterval), animations: ()-> Void)'
Run Code Online (Sandbox Code Playgroud)

如果我在完成闭包之外的某个地方调用它就可以了.

closures uiview uianimation completionhandler swift

11
推荐指数
1
解决办法
3560
查看次数

Swift中的UIView动画不起作用,错误的参数错误

我正在尝试制作动画并使用下面的代码.我得到"无法使用类型'的参数列表调用'animateWithDuration'(FloatLiteralConvertible,延迟:FloatLiteralConvertible,选项:UIViewAnimationOptions,动画:() - >() - > $ T4,完成:(布尔) - >(Bool ) - > $ T5)'"错误.

这意味着我使用了错误的参数.我错了.请帮忙.我无法真正解决它.

var basketTopFrame = CGRect()
basketTopFrame = dropPlace.frame
var mytimer : NSTimer = NSTimer .scheduledTimerWithTimeInterval(2.0, target: self, selector: "restart", userInfo: nil, repeats: false)

UIView.animateWithDuration(1.0, delay: 0.1, options: UIViewAnimationOptions.CurveEaseIn , animations: {  var pickPlace = basketTopFrame }, completion:  {(finished: Bool) in mytimer })
Run Code Online (Sandbox Code Playgroud)

提前致谢.

uiviewanimation ios swift

7
推荐指数
1
解决办法
2899
查看次数