我做得很好,但仍显示错误“ViewController不确认协议” 我在这个网站上搜索很多我找到相同的问题,但没有找到任何正确的答案 我已经添加连接向的UITableView和的UITableViewDelegate但UITableViewDataSource仍然显示我应该怎么办ViewController不确认协议UITableViewDataSource
错误的,这里是我的代码
class ViewController: 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.
}
@IBOutlet var tableView: UITableView!
func tableView(tableView:UITableView!, numberOfRowsInSection section:Int) -> Int
{
return 20
}
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!
{
let cell:UITableViewCell=UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "mycell")
cell.textLabel.text="row#\(indexPath.row)"
cell.detailTextLabel.text="subtitle#\(indexPath.row)"
return cell
}
}
删除此“!”后,仍然显示相同的错误 – suthar 2014-10-08 11:03:56
你确定你抓住了所有四个'!'?当我编译代码时,我发布了错误消息更改。 – fluidsonic 2014-10-08 11:26:13
解决了谢谢 – suthar 2014-10-08 11:43:23