【发布时间】:2015-11-06 19:55:05
【问题描述】:
我有一个 ViewController 使用这个函数调用(点击一个按钮)另一个视图
@IBAction func btnSeeContact(sender: AnyObject) {
self.performSegueWithIdentifier("segueSeeContact", sender: self)
}
我的原型单元被“链接”到我创建并实现的名为 ContactsTableViewCell 的自定义视图控制器:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! ContactsTableViewCell
cell.txtName.text = "test"
cell.txtPhone.text = "1234567890"
return cell
}
当我运行项目时,按钮调用了表格,但上面没有 Cell,我在那些 tableView 函数上设置了一个断点,它们没有被访问。
我在这里错过了什么,这些函数永远不会被调用?
【问题讨论】:
-
您能否展示您的故事板的屏幕截图以便更好地理解?
-
你写的是
prototype cell is "linked",是Storyboard中的单元格标识符吗? -
也许您在包含表格视图的视图控制器的故事板中使用了错误的类名。这是您的 segue 所指向的。所以也许它根本不会加载您的自定义视图控制器。
-
截图中的这个 TableViewController 是由导航控制器创建的。我创建的唯一其他视图控制器是 ContactsTableVillCell,它保留了单元格的标签。诸如“numberOfRowsInASection”之类的功能在主视图控制器中实现
标签: ios swift uitableview ios9 xcode7