【发布时间】:2017-01-11 00:29:36
【问题描述】:
在模拟器中运行我的 Xcode 项目时,我的UIViewController(不是UITableViewController)中的UITableView 是黑色的。
这是我的模拟器的图像:
我的cellForRowAtIndexPath 方法的代码:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cellIdentifier = "Cell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! MyPinpointsTableViewCell
// Configure the cell...
cell.titleLabel.text = myPinpoints[indexPath.row].title
cell.locationLabel.text = myPinpoints[indexPath.row].location
cell.dateLabel.text = myPinpoints[indexPath.row].date
cell.pinpointImage.image = UIImage(data: myPinpoints[indexPath.row].image)
return cell
}
这是我拥有的文件夹:
Main.storyboard:
将print(myPinpoints) 添加到numberOfRowsInSection 时收到的错误消息
[(实体:详细信息;id:0xd000000000080000;数据:)] [(实体:详细信息;id:0xd000000000080000;数据:)] [(实体:详细信息;id:0xd000000000080000;数据:)] [(实体:详细信息;id:0xd000000000080000;数据:)] [(实体:详细信息;id:0xd000000000080000;数据:)] [(实体:详细信息;id:0xd000000000080000;数据:)] [(实体:详细信息;id:0xd000000000080000;数据:)] [(实体:详细信息;id:0xd000000000080000;数据:)] [(实体:详细信息;id:0xd000000000080000;数据:)] [(实体:详细信息;id:0xd000000000080000;数据:)] [(实体:详细信息;id:0xd000000000080000;数据:)]
【问题讨论】:
-
是否使用数据源?
-
@MarcoSantarossa 我正在使用 Core Data 数据源
-
登录
cellForRowAtIndexPath并确认您的tableview 中的delegate和dataSoruce是否正常工作 -
@pedrouan 好的。感谢您的提醒。我现在看到了。您有什么方法可以建议我们解决这个问题吗?
-
如果更改
tableview中的background color,是否会应用更改?
标签: ios swift uitableview ios-simulator