将 UITableView 放入 UIView 时遇到问题。
我设置了一个委托(delegate)和数据源并实现了所有方法。
这是我的 UIView 类。
@objc class ChooserView: UIView, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var backgroundView: UIView!
@IBOutlet weak var showView: UIView!
@IBOutlet weak var tableView: UITableView!
public class func createChooserView() -> ChooserView {
var view: ChooserView!
view = Bundle.main.loadNibNamed(String(describing: ChooserView.self), owner: self, options: nil)?.first as! ChooserView
_ = MLAutolayouts.fillContainer(UIApplication.shared.keyWindow!.subviews.first!, view: view)
//Register cell nib
view.tableView.register(UINib(nibName: "PhoneCell", bundle: nil), forCellReuseIdentifier: "PhoneCell")
return view
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: PhoneCell.self)) as! PhoneCell
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("TAP...")
}
}
这就是导出
当运行我的应用程序时。我收到此错误
-[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7fded2e772d0
记录图像。
任何想法...
谢谢。
最佳答案
关于ios - Swift 3.0 中 UIView 内的 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41986560/