I am pretty new to Iphone development . so please bear me if I ask some very simple questions.
In my application I have multiple views(i.e. .xib files). On clicking
Did you make sure to set the table view as the delegate?
If you have a UITableViewController, you this need in viewDidLoad:
[self.tableView setDelegate:self];
If you have another type of view controller, just make the UITableView an IBOutlet, make the connections to the file owner for tableViewDelegate and tableViewDataSource then do this in viewDidLoad:
[self.myTableProperty setDelegate:self];
Also make sure to conform to the UITableViewDelegate and UITableViewDataSource protocols in your .h file if the View Controller is not a UITableViewController
Cheers
Well, I can add one simple point for everyone with this problem. I would recommend using debug and making sure that:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
does not return 0. If this function is not implemented or if it returns 0, the method:
cellForRowAtIndexPath:(NSIndexPath *)indexPath
is not called at all since there are no cells to be displayed.
I suggest you make sure that the size of the table requires rows to be displayed.
Indeed, it could be a case for why the method cellForRowAtIndexPath
is not called, however the numberOfRowsInSection
should be called.
In this case you'll not see anything in your table.
I'm not positive but here are some ideas.
viewDidLoad
it's too late. ViewDidLoad
is executed after the data has already been placed in the table. Try putting this code in the initWithStyle method or whatever init
method you have. Or you could even put it int the ViewWillAppear
method, but then make sure to follow this next suggestion.[self.tableView reloadData]
at the end of the viewDidLoad
method. Although that's not as ideal as the first suggestion.Check that the tableview has been added to the view. If not then other table view delegate and datasource methods will be fired but not cellforrow :)
Are you sure you set your class as the dataSource on the table? To do this, control+click on the table view in Interface Builder and drag it onto the File's Owner under Placeholders. Then select dataSource (and probably delegate too, depending on your controller-view setup).