高手看过来!求解,坐等回复啊!看了好几天,没有头绪。
新版ios12下,苹果手机运行某项目,提示我必须用Xcode10来编译。
我就安装了Xcode10,但编译得到一个错误:'self' used before 'super.init' call。急着上线!
注:原代码在iOS11下正常编译通过。
zhubajie网另有500元相送,请看:https://task.zbj.com/178666556044099584
调用方的成员函数如下:
------------------------
static func showPrize(imgUrl:String?,buttonActionBlock:(()->())?) {
guard let _imgUrl = imgUrl else { return }
KingfisherManager.shared.retrieveImage(with: URL.init(string: _imgUrl)!, options: nil, progressBlock: nil) { (image, error, cacheType, url) in
guard let _image = image else { return }
let backgroundView = UIView(frame: UIScreen.main.bounds)
backgroundView.backgroundColor = UIColor.black.withAlphaComponent(0.7)
backgroundView.alpha = 0
UIApplication.win.addSubview(backgroundView)
let htw_scale = _image.size.height / _image.size.width
let width = UIScreen.main.ScreenWidth - 48 * 2
let height = width * htw_scale
let view = AlertView(frame: .init(x: 48, y: ( UIScreen.main.ScreenHeight - height ) / 2.0, width:width , height:height))
view.backgroundColor = UIColor.white
view.layer.cornerRadius = 4
view.layer.masksToBounds = true
let poster = UIImageView.init(image: _image)
view.addSubview(poster)
poster.contentMode = .scaleToFill
poster.snp.makeConstraints { (make) in
make.edges.equalToSuperview()
}
view.alpha = 0
view.addGestureRecognizer(CLUITapGestureRecognizer.init(block: {[weak view] in
buttonActionBlock!()
view?.isHidden = true
UIView.animate(withDuration: 0.2, animations: {
backgroundView.alpha = 0
}, completion: { (b) in
backgroundView.removeFromSuperview()
view?.removeFromSuperview()
})
}))
UIApplication.win.addSubview(view)
view.transform = CGAffineTransform.init(scaleX: 0, y: 0)
UIView.animate(withDuration: 0.3) {
view.transform = CGAffineTransform.init(scaleX: 1, y: 1)
backgroundView.alpha = 1
view.alpha = 1
}
}
}
被调方的整个文件如下:
-----------------------------
import UIKit
class CLUITapGestureRecognizer: UITapGestureRecognizer {
public typealias _ActionBlock = ()->()
private var _block:_ActionBlock?
deinit {
CLLog(message: "CLUITapGestureRecognizer dealloc")
}
init(block:@escaping(_ActionBlock)) {
self._block = block
super.init(target:self, action: #selector(CLUITapGestureRecognizer._action))
}
@objc private func _action(){
_block?()
}
}