views:

122

answers:

1

The tableViewHeader property of UITableView is a UIView so I thought I would be able to add multiple sub-views to it. However, when I added the code for the segmented control the UILabel a few lines before it doesn't draw. Rects shouldn't be overlaping each other.

What am I doing wrong?

- (void)viewDidLoad {
[super viewDidLoad];

CGRect newFrame = CGRectMake(0.0, 0.0, self.tableView.bounds.size.width, 50.0);
UIView *trialHeaderView = [[UIView alloc] initWithFrame:newFrame];
trialHeaderView.backgroundColor = [UIColor clearColor];

UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(15.0, 10.0, 75.0, 25.0)] autorelease];
label.font = [UIFont boldSystemFontOfSize:12.0];
label.text = @"TaDa!";
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor blackColor];
[trialHeaderView addSubview:label];
[label release];

CGRect frame = CGRectMake(80, 10, 100, 35);
UISegmentedControl *seg = [[UISegmentedControl alloc] initWithFrame:frame];
[seg insertSegmentWithTitle:@"Start" atIndex:0 animated:NO];
[seg insertSegmentWithTitle:@"End" atIndex:1 animated:NO];
[trialHeaderView addSubview:seg];

[seg release];

self.tableView.tableHeaderView = trialHeaderView;
[trialHeaderView release];

}

A: 

Should have updated this earlier...I had autoreleased AND released the same object. silly me...

Meltemi