【发布时间】:2016-04-21 10:08:10
【问题描述】:
我在UITableViewCellController 上有一个笔尖作为自定义单元格。有一个带有识别器的 UIView。而且,我在cellForRowAtIndexPath里面添加了笔尖,但是我不能点击笔尖上的UIView。
CustomButton.swift(我跳过了tapRecognizer,因为在这里显示并不重要):
class CustomButton: UIView {
var tappable = false
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(CustomButton.tapRecognizer))
self.addGestureRecognizer(tapGestureRecognizer)
}
}
这是笔尖的代码:
@IBOutlet weak var customButton: CustomButton!
override func awakeFromNib() {
self.customButton.tappable = true
}
UITableViewCellController中的代码:
override func viewDidLoad() {
// register nib
let nib = UINib(nibName: "CustomCell", bundle: nil)
self.tableView.registerNib(nib, forCellReuseIdentifier: "customNib")
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("customNib") as! CustomCell
return cell
}
当我尝试调试视图层次结构时,整个页面(包括按钮(橙色))都被 UITableViewCellContentView 覆盖。
我是否遗漏了代码中的某些内容?
【问题讨论】:
标签: ios swift uitableview uiview