I have a custom view EMViewController with a tableview as a subview. I want EMViewController to double as the controller for the subview, so I have it set as the delegate and dataSource.
// EMViewController.h
@interface EMViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
...
// EMViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
self.eTableView.delegate = self;
self.eTableView.dataSource = self;
}
I’m populating the data with an asynchronous array/dictionary from Facebook, so once I have the data, I run
[self.eTableView reloadData]
For the UITableViewDataSource protocol methods, I implemented the following:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
NSLog(@"returns sections 0"); // This appears in my log
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"returning count %d", [self.eList count]); // never shows up
return [self.eList count];
}
- (EMTableViewCell *)tableView:(EMTableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// configure the cell
NSLog(@"index: %d", indexPath); // never shows up
...
}
So far, I have already tried:
- making sure my storyboard is connected up
- checking/rechecking the delegate/dataSource being set in viewDidLoad
- completely restarting/clean-building my app just in case
- creating a placeholder UIView subclass (although I’m not changing much)
- creating a customUITableViewCell class with outlets for my custom layout (images, 3 labels)
- testing out strong/weak references to the tableView outlet
Any advice would be appreciated. I think my problem is similar to this question, except I’m trying to add the tableview as a subview. My end goal is to populate the cells with a custom format that includes an image and three labels. Thanks!
Return 1 section instead of returning 0 sections