我有一个设置了视图控制器的故事板。视图控制器分为两部分,一部分是UI日期选择器,另一部分是表视图。当我设置视图控制器为委托和数据源,我得到将表格视图添加到UI视图控制器错误
reason: '-[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7fdb29b4d9e0'
我的视图控制器通过以下方式
import Foundation
import UIKit
class CustomViewController: UIViewController , UITableViewDelegate , UITableViewDataSource{
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return 3;
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
var sampleCell = tableView.dequeueReusableCellWithIdentifier("cell") as! UITableViewCell
return sampleCell;
}
}
,你是对的! – user1801279
很高兴我帮助:)谢谢,现在我可以评论无处不在哈哈:) –