I have a UITableView and I want the first cell of this UITableView to be a description of what is being showed so this will take up a few lines and then the rest of the cells are the hours of operation. I have the table view set up like this. And I am wondering how to set the first cell so that the height of it matches the amount of room need to fit the text:
- (void)viewDidLoad {
[super viewDidLoad];
array = @[@{@"days":@"sdalkfjsadklfjlak8 aslfkjsakljf sdakljfsalkdjfs dfkljsdakfjkjlfjsakkjja"},
@{@"days":@"Mon-Fri", @"time":@"9-10"},
@{@"days":@"Sat", @"time":@"10-3", @"tag":@"0"},
@{@"days":@"Sun", @"time":@"3-3"} ];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return diningHallTimes.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.row) {
case 0:
return 60;
break;
default:
return 40;
break;
}
}
So how would the best way to set it so that the text always fits in the height of the first cell?
Thanks for the help