Bal*_*kar 1 uitableview ios swift
所以,这是一个多页面应用程序,每当我切换到其中存在UITable的页面时,我面临这个错误"setValue:forUndefinedKey:]:这个类不是键值表符号的键值编码." 我之前得到了同样的错误,因为我忘了添加numberOfRowsInSection函数,但即使在添加之后我仍然面临同样的错误.
class workingQuery: UIViewController, UITableViewDelegate, UITableViewDataSource{
@IBOutlet weak var tableViews: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated
}
//TableView Code
var names = ["Mark", "Cloyd", "Buck", "Steve", "Wallace"]
var breeds = ["Labrador Retriver", "Bulldog", "German Shepherd", "Golden Retriver", "Yorkshire"]
var images = [UIImage(named:"johnny"), UIImage(named:"dusra"), UIImage(named:"Third"), UIImage(named:"Fourth"), UIImage(named:"Fifth")]
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 5
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.tableViews.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! CustomCell
cell.photo.image = images[indexPath.row]
cell.fullName.text = names[indexPath.row]
cell.ageSex.text = breeds[indexPath.row]
return cell
}
}
Run Code Online (Sandbox Code Playgroud)
打开Storyboard(或Xib)并单击"File's Owner".
选择:查看 - >实用程序 - >显示连接检查器
你会看到一个带有感叹号的连接:
单击X删除此连接,构建并运行.
| 归档时间: |
|
| 查看次数: |
1234 次 |
| 最近记录: |