[英]UITable, How to assign a delegates to UITable In Swift IOS
我有一个UITable链接到我的viewController
,它具有DataSource
和Delegate
扩展名。 但是,当我查看视图控制器上的连接时,它们未链接,并且无法弄清楚如何链接它们,对您有所帮助。
IB插座
@IBOutlet weak var locationTableView: UITableView!
当前代码扩展findCacheViewController:UITableViewDataSource {
//Number Of Rows (Return Value)
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return cacheData.count
}
//Table Content
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = locationTableView.dequeueReusableCellWithIdentifier("Cell")
let cellData = cacheData[indexPath.row]
let titleLabelCell = cell?.viewWithTag(1) as! UILabel
let typeLabelCell = cell?.viewWithTag(2) as! UILabel
let distanceLabelCell = cell?.viewWithTag(3) as! UILabel
if userCurrentLocation == nil {
titleLabelCell.text = "Location Required"
typeLabelCell.text = ""
distanceLabelCell.text = ""
} else {
titleLabelCell.text = "\(cellData.memoryTitle)"
typeLabelCell.text = "\(cellData.memoryType)"
}
return cell!
}
}
扩展名findCacheViewController:UITableViewDelegate {
//Row Height Based On Condition
//func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
//let cellData = cachedata[indexPath.row]
//if conditions {
//}
//}
//Selected Cell Segue Function
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
selectedCell = cacheData[indexPath.row]
//performSegueWithIdentifier(<#T##identifier: String##String#>, sender: self)
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.