高手看过来!求解,坐等回复啊!看了好几天,没有头绪。

weixin_39508985 2018-11-22 11:32:23
新版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?()
}
}
...全文
631 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_44037088 2018-12-10
  • 打赏
  • 举报
回复
上下順序對調一下 super.init(target:self, action: #selector(CLUITapGestureRecognizer._action)) self._block = block
qq_37940437 2018-12-06
  • 打赏
  • 举报
回复
self因该是不能作为super.init的参数的,这个在哪个版本都编译不过去
Nov_J 2018-12-05
  • 打赏
  • 举报
回复
self因该是不能作为super.init的参数的,这个在哪个版本都编译不过去

29,049

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧