Ceci est mon programmeComment faire pour définir la hauteur de la cellule progamatically sans utiliser le fichier nib?
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
self.title = @"Library";
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(close:)];
// self.tableView.rowHeight = 80;
}
-(void)close:(id)sender
{
//
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{ cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
UILabel *dateLabel = [[UILabel alloc]init];
dateLabel.frame = CGRectMake(85.0f, 6.0f, 200.0f, 20.0f);
dateLabel.tag = tag1;
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
cell.contentView.frame = CGRectMake(0.0f, 0.0f, 320.0f, 80.0f);
[cell.contentView addSubview:dateLabel];
[dateLabel release];
}
// Set up the cell...
//[(UILabel *)[cell viewWithTag:tag1] setText:@"Date"];
cell.textLabel.text = @"Date";
return cell;
}
Je suis en train de la taille du cadre de la cellule dans tableView mais la cellule est en taille par défaut uniquement. Je veux dire que la hauteur que j'avais fixée était de 80 mais elle n'était pas fixée à 80 en hauteur. Comment puis-je le faire.
Merci Vous
Merci. Cela a fonctionné. J'ai utilisé - [UITableViewDelegate tableView: heightForRowAtIndexPath:] –