user3335123
user3335123

Reputation: 1

iOS Simulator doesn't show prototype cell

I'm currently learning Objective-C by doing tutorials ("the iOS Apprecente") Now I need to make a checklist

I added in viewController.h

@interface ViewController : UITableViewController 

Normal there stands

@interface ViewController : UIViewController

The next is to go to Storyboard place there a TableViewController, give it the name: ChecklistsViewController (Identity inspector > Custom class > class. I added a label into the first Table view cell. But when I run it there's nothing.

What to do?

Upvotes: 0

Views: 211

Answers (1)

Rob
Rob

Reputation: 438437

Two separate issues here:

  1. The choice of UIViewController with your own IBOutlet for the table view or a UITableViewController is simply a question of whether, in Interface Builder (IB), you added a standard view controller to which you added a table view, or whether you used a table view controller. You use the former if you have other controls on the view in addition to the table view. You'd generally use the latter if the table view is the only thing being presented in that view controller's view. Bottom line, your choice of UIViewController or UITableViewController is dictated by how you added the scene in IB. From your description, it sounds like you went down the UITableViewController approach, which is fine.

  2. In terms of why you're not seeing anything, there are a bunch of possible reasons:

    • Did you specify the cell identifier for your table view cell prototype? Is it the same identifier you're using in cellForRowAtIndexPath method?

    • If you manually added a table view to a standard view controller's view, did you specify the view controller as the delegate and dataSource for the table view? Also, did you create an IBOutlet for the table view itself, hooking that up in IB? (If you used a table view controller in Interface Builder, you don't have to do these steps.)

    • You might want to double-check that the base class for the table view controller was correctly set in IB.

    • Did you implement all of the UITableViewDataSource methods, notably numberOfRowsInSection? If you don't do that, it will conclude that there are no rows, and no cells will be generated.

    • You say that you specified the base class for your view controller in IB to be ChecklistsViewController. But in your code snippets, it looks like you're using a custom class called ViewController. Make sure you're using the same UITableViewController subclass for both.

Upvotes: 2

Related Questions