Videos
References
Further reading
Category:DLLs
Category:Expatriate softwareQ:
How to correctly format an ios responsive table view cell
I'm having some issues trying to format my table view cells on an ios app.
Basically I have a group of 4 cells, and in each cell i have a label which is supposed to take up all the remaining height of the cell, and the rest of the cell is supposed to be a background image (ie. rectangle), using the following style code:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0) {
return 120;
} else if (indexPath.row == 1) {
return 100;
} else if (indexPath.row == 2) {
return 80;
} else {
return 60;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
if (indexPath.row == 0) {
cell.textLabel.text = @"test 0";
cell.detailTextLabel.text = @"test 0";
} else if (indexPath.row == 1) {
cell.textLabel.text = @"test 1";
cell.detailTextLabel.text = @"test 1";
} else if (indexPath.row == 2) ac619d1d87
Related links: