Akkordeon Tabellenzelle - zum erweitern und reduzieren ios

Ich versuche, aus - /Zuklappen von tableview-Zellen in Akkordeon-Zell-Muster, So dass, wenn ein Benutzer tippt auf die Zeile, die Sie würden, Holen Sie sich die detaillierte Beschreibung der ausgewählten Zeile innerhalb der Zelle durch die Verlängerung der Zeilenhöhe. Ich habe 2 arrays 'array' und 'detailarray' für die Anzeige in der Zelle.textLabel.text' und 'Zelle.detailTextLabel.'text in Zellen resp. nun anfangs habe ich gemacht 'Zelle.detailTextLabel.hidden = YES' wie versteckt, so dass, wenn der Benutzer tippt auf die Reihe bekommen kann der erweiterte text der Zelle.

Mein code,

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    //Configure the cell...
    cell.textLabel.text=[array objectAtIndex:indexPath.row];
    cell.detailTextLabel.text=[detailarray objectAtIndex:indexPath.row];
    cell.detailTextLabel.hidden = YES;

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath  *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSLog(@"indexpath is %d", indexPath.row);
    selectedIndex = indexPath.row;
    isSearching = YES;

    [self.tableview beginUpdates];

    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    cell.textLabel.text=[array objectAtIndex:indexPath.row];
    cell.detailTextLabel.text=[detailarray objectAtIndex:indexPath.row];
    cell.detailTextLabel.hidden = NO;

    [self.tableview endUpdates];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (isSearching && indexPath.row == selectedIndex)
    {       
        return 77;      
    }
    return 44;    
}

Nun habe ich eine tableviewcell mit 4 Zeilen und beim Tippen jede Zeile, ich würde die erweiterte Ansicht der ausgewählten Zeile.
Während der Laufzeit konnte ich sehen, die 'detailarray' text auf mein Handy, wenn es erweitert, aber es verschwindet, wenn didselectRowAtIndexPath-Funktion gestoppt ist, warum passiert das so, kann jemand mir helfen in dieser Hinsicht.

Hier ist die gleiche Frage, wie bei Ihnen. Sie können auch folgende tutorials für demos ; 1) Demo1 2) Demo2 3) Demo3 Hoffe das hilft.

InformationsquelleAutor sathya | 2013-09-04

Schreibe einen Kommentar