关于动画:Swift Closure – 无法转换类型 (_) -> () 的值?到预期的参数类型(()->())? | 珊瑚贝

Swift Closure – Cannot convert value of type (_) -> ()? to expected argument type (() -> ())?


我在 Xcode 9、Swift 4 中使用 SideMenuController pod。试图让侧面板动画正常工作。无法弄清楚为什么它会抛出这个错误。如果您能提供帮助,请提前致谢!

1
2
3
4
5
6
7
8
9
UIView.panelAnimation( duration, animations: {
        self.centerPanel.frame = centerPanelFrame
        self.set(statusUnderlayAlpha: hidden ? 0 : 1)
    }) { _ in  // THROWS ERROR – CANNOT CONVERT VALUE OF TYPE (_) -> ()? TO EXPECTED ARGUMENT TYPE (() -> ())?
        if hidden {
            self.setSideShadow(hidden: hidden)
        }
        completion?(updated)
    }

这是该函数的定义:

1
class func panelAnimation(_ duration : TimeInterval, animations : @escaping (()->()), completion : (()->())? = nil)

如您所见,您不需要在完成闭包开始时使用 _ in 关键字。

改写如下:

1
2
3
4
5
6
7
8
9
UIView.panelAnimation( duration, animations: {
    self.centerPanel.frame = centerPanelFrame
    self.set(statusUnderlayAlpha: hidden ? 0 : 1)
}) {
    if hidden {
        self.setSideShadow(hidden: hidden)
    }
    completion?(updated)
}


来源:https://www.codenong.com/46424290/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_8752.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?