How do I change the width of a table view header??
I have a UITableView, and a header which is a UIImageView set in ViewForHeaderInSection.
When I run the app the header stretches to the width of the screen, while the rows (also images) are the width I want.
The height seems to be ok, it’s just the width that’s the problem.
When I create the Image to set as the header I make a frame for it, but it doesn’t do anything.
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIImage *tableHeaderImage = [UIImage imageNamed:@"tableTop"];
UIImageView *headerImageView = [[[UIImageView alloc] initWithImage:tableHeaderImage] autorelease];
headerImageView.frame = CGRectMake(0,0,277,7);
NSLog(@"%@",headerImageView.frame.size.width);
return headerImageView;
}
p.s. it is all programmatically coded.
You need to return a
UIView. Once you have set one up add the image view as a subview and return the view: