I have a UIView which contains a UITableView. The tableview's delegate is set to my UIView, but it never calls the delegate methods:
-(id)init {
self = [super init];
if (self) {
self.tableView = [[UITableView alloc] initWithFrame:self.bounds];
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.tableView.dataSource = self;
self.tableView.delegate = self;
self.tableView.scrollEnabled = NO;
self.tableView.layer.cornerRadius = PanelCornerRadius;
[self addSubview:self.tableView];
}
return self;
}
#pragma mark - UITableViewDelegate methods
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"height for row");
int height = [self heightForRowAtIndexPath:indexPath];
return height;
}
#pragma mark - UITableViewDataSource methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"number of rows");
if (self.manager.fetchOperation.dataFetchProblem) {
return 1;
}
int numberOfRows = [self.delegate numberOfSectionsInPanel:self];
return numberOfRows;
}
I've explored every option I can think of, but can't seem to find the root of the problem.
EDIT: Included the numberOfRowsInSection. It could potentially return 0, only it never gets that chance because the "number of rows" NSLog never gets called.
I ran into the same issue once, what silly mistake I did was inside initWithCoder I called [super init]. TableView was in xib
Instead of
Just check if that's not the case
Can you please write the code that you have written on your cellForRowAtIndexPath: method? Because i can't find anything wrong with your code.
Are you calling your UIView from some other ViewController? If yes, how?
I have done something like this once. I declared a method in the UIView like this :
And then i called the setUpTableView from the view controller i added this view to, like this :
This might help. Thanks.