I have a UITableView that needs to have something inserted at the top in some cases (not always).
The code (if it were to be a NORMAL) cell would be as follows
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,98,100)];
imgView.image = [UIImage imageNamed:@"image.png"];
cell.imageView.image = imgView.image;
//sets cell text
cell.textLabel.text = @"Number";
but I was told on here that it would be easier to implement a headerView than to change the indexPath each time.
So my question is how would I implement this? Would I use - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section or would I use - (NSString *)tableView:(UITableView *)aTableView titleForHeaderInSection:(NSInteger)section? Keep in mind, I have an image to place into the cell (headerView).
Thanks
You would use
titleForHeaderInSection:only sets the header as text, where asviewForHeaderInSection:will allow you to add a view,UIImageView, etc.