Tabelle anzeigen mit benutzerdefinierter Zellen (programmgesteuert)
So weit, dass ich verwendet zum erstellen von benutzerdefinierter Federn machen meiner Zelle, wie ich wollte, aber dieses mal, die Höhe einer Zelle ändern von einem zum anderen, so dass I kann nicht erstellen Sie eine Feste Größe-cell nib.
Also habe ich beschlossen, erstellen Sie programmgesteuert ... Ist der Weg unterhalb der guter Weg, es zu erreichen ?
//Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
UILabel *pseudoAndDate = [[UILabel alloc] initWithFrame:CGRectMake(0.0,0.0,320.0,20.0)];
[pseudoAndDate setTag:1];
[cell addSubview:pseudoAndDate];
[pseudoAndDate release];
}
CommentRecord *thisRecord = [comments objectAtIndex:[indexPath row]];
UILabel *label = (UILabel *)[cell viewWithTag:1];
[label setText:[NSString stringWithFormat:@"%@ | %@",thisRecord.author,thisRecord.date]];
return cell;
}
.. oder bin ich hier etwas fehlt ? Ursache so weit es scheint nicht zu funktionieren 😉
Dank,
Gotye.
InformationsquelleAutor gotye | 2010-03-27
Du musst angemeldet sein, um einen Kommentar abzugeben.
Warum ein label erstellen, wenn Sie nicht müssen? Verwenden Sie die UITableViewCell ' s label.
InformationsquelleAutor Nate Symer
Wenn Ihr problem ist, dass die Höhe variiert von Zelle zu Zelle können Sie die Methode verwenden:
Vom UITableViewDelagate, es zu erreichen
InformationsquelleAutor mspapant
Neues link für custom UITableViewCell programmgesteuert Apple-Dokumentation UITableViewCell
InformationsquelleAutor gotye