UITableViewCell mit UITableViewCellStyleValue1, hinzufügen neue Zeile zu detailTextLabel an der Zelle an der Unterseite

auf meinem tableview habe ich die Letzte Zelle, die ursprünglich nicht sichtbar, wie man im ersten Bild, wenn ich durch die Liste scrollen, bis Sie sehen können, im zweiten Bild, dass der Preis oder meine detailTextLabel ist auf einer neuen Zeile nicht die Aufrechterhaltung der richtigen Begründung.


Bild 1 http://img706.imageshack.us/img706/4496/iphoneerror1.jpg

Bild 2 http://img706.imageshack.us/img706/6007/iphoneerror2edited.jpg


Hier ist der code, ich kann nicht herausfinden, warum sein dies zu tun, jede Richtung oder Hilfe wäre sehr geschätzt werden

- (UITableViewCell *)tableView:(UITableView *)ltableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [ltableView dequeueReusableCellWithIdentifier:CellIdentifier];    
    //Configure the cell.
    NSUInteger indexRow = [indexPath row];
    switch (indexRow) {
        case 0:{
            NSCharacterSet *set = [NSCharacterSet whitespaceCharacterSet];
            NSString *description = [[currentData objectForKey:@"Description"] stringByTrimmingCharactersInSet:set];

            if (cell == nil) {
                    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
            }
            cell.selectionStyle =  UITableViewCellSelectionStyleNone;
            cell.accessoryType = UITableViewCellAccessoryNone;
            cellShift = 1;


            if (![description isEqualToString:@""]) {
                cell.textLabel.text = @"";
                cell.detailTextLabel.text = description;
                cell.detailTextLabel.numberOfLines = 2;
            }
            else {
                cell.textLabel.text = @"";
                cell.detailTextLabel.text = @"";
                cell.detailTextLabel.numberOfLines = 0;


            }
            break;
        }
        default:{
            if (cell == nil) {
                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
            }
            NSDictionary *item = [tableData objectAtIndex:(indexRow-cellShift)];
            NSString *name = [item objectForKey:@"Name"];
            if ([name length] > MaxVendorsLength ) {
                name =  [NSString stringWithFormat:@"%@ ...",[name substringToIndex:MaxVendorsLength]];
            }
            cell.textLabel.text = name;
            cell.textLabel.minimumFontSize = 12;

            NSString *priceString;
            float price = [[item objectForKey:@"Price"] floatValue];
            //NSLog(@"| %@ | : | %@ |",[item objectForKey:@"Name"], [item objectForKey:@"Price"]);
            if (price != 0) {
                priceString = [[NSString alloc] initWithFormat:@"$%.2f",price];
            }
            else {
                priceString = [[NSString alloc] initWithString:@"--"];
            }

            cell.detailTextLabel.text =  priceString;

            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            [priceString release];          
            break;
        }
    }
    cell.textLabel.font = [UIFont boldSystemFontOfSize:15];
    cell.textLabel.minimumFontSize = 14;
    cell.detailTextLabel.font = [UIFont boldSystemFontOfSize:15];
    cell.detailTextLabel.minimumFontSize = 14;
    return cell;
}

Lassen Sie mich wissen, wenn ich brauche, um etwas anderes zu bekommen, helfen mit diesem ???

InformationsquelleAutor slim | 2010-05-28

Schreibe einen Kommentar