Eugene Trapeznikov
Eugene Trapeznikov

Reputation: 3240

How to use UITableView

I got UITableView in simple view, which controlled by UIViewController

I implement methods like in standard UITableViewController:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

But it doesnt work. Nothing showes in the table

How can i upload the data to this UITableView?

Upvotes: 0

Views: 843

Answers (2)

Gengis
Gengis

Reputation: 171

  • Did you set the dataSource property of the UITableView to point to your UIViewController?
  • Declare your controller as adhering to the <UITableViewDataSource> protocol, in this way you will receive some warning if you missed to implement some required method.

Are you trying to use an UIViewController in place of a UITableViewController? Why? (As Damien said, this should be the first question).

Upvotes: 3

Damien Del Russo
Damien Del Russo

Reputation: 1048

Sorry if this is a dumb question, but why not use the actual UITableViewController? You can embed it in a UIViewController and make it smaller if you want (like the iOS "Stocks" app from Apple).

There is a lot going on with tableView, which is why when you create a new UIViewController subclass it asks specifically if you want to subclass UITableViewController or UIViewController. Of course you can get it to work, but a good first question is why not use UITableViewController?

Again sorry if that isn't really answering the question directly.

Good luck,

Damien

Upvotes: 1

Related Questions