When running my Xcode project in the simulator, my UITableView
in my UIViewController
(not UITableViewController
) is black.
Here is an image of my simulator:
Code for my cellForRowAtIndexPath
method:
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
}
Here are the folders that I have:
Main.storyboard
:
The error message I get when I add print(myPinpoints)
to numberOfRowsInSection
[ (entity: Details; id: 0xd000000000080000 ; data: )] [ (entity: Details; id: 0xd000000000080000 ; data: )] [ (entity: Details; id: 0xd000000000080000 ; data: )] [ (entity: Details; id: 0xd000000000080000 ; data: )] [ (entity: Details; id: 0xd000000000080000 ; data: )] [ (entity: Details; id: 0xd000000000080000 ; data: )] [ (entity: Details; id: 0xd000000000080000 ; data: )] [ (entity: Details; id: 0xd000000000080000 ; data: )] [ (entity: Details; id: 0xd000000000080000 ; data: )] [ (entity: Details; id: 0xd000000000080000 ; data: )] [ (entity: Details; id: 0xd000000000080000 ; data: )]
You may miss some stuff:
1) Check whether your tableView has set the class named as that on in your code. You find the input field to type the name of the class in Attributes inspector of the tableView.
2) Check whether you implemented methods, that comform to UITableViewDelegate and UITableViewDataSource Protocol.
3) Check whether your table is properly connected from Storyboard to your UIViewController =>
As your tableView is inside UIViewController, check whether you set delegate and datasource for tableView in your controller (CTRL drag from table to FileOwner - rounded yellow icon in storyboard scene frame.)
4) Make sure, you set protocols that your UIViewController should conform to - i.e. delegate and dataSource protocols:
5) Check your datasource, as it may not be returning any items in
cellForRow()
method. It can by simply tested inprint(dataSource)
in any of TableView's delegate methods.6) Check possible autolayout issues, as the important subviews could be out of visible part of the view.