2010-12-02 16 views
-1
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; 

après j'augmente la hauteur de la 1ère cellule heightforRowAtIndexPath. Mais à ma grande surprise, il augmente la hauteur de la deuxième cellule, mais quand je fais défiler la vue de la table ... la hauteur de la première est remise à désiré.UITableViewCell reloadcellsAtIndexPaths augmente la hauteur de la cellule suivante, mais pas la réelle un

Si je recharge Toute aide sur ce serait utile ..

+0

Vous aurez probablement besoin de montrer un peu plus de code pour obtenir de l'aide avec celui-ci. Est-ce la même chose si vous faites juste [table reloadData] et rafraichissez le tout? –

+0

j'ai fait les changements à la description .. merci Adam. – jacob

+0

ouais - '[tv reloaddata]' est définitivement un peu plus de code. – vikingosegundo

Répondre

0

toute la table en utilisant [TV reloadData] il fonctionne très bien .. ne fonctionne pas seulement si je fais la cellule particulière

Comme écrit dans les commentaires ci-dessus, j'ai seulement une vague compréhension de ce que vous voulez réaliser. Je supposons que vous souhaitez étendre la cellule en modifiant leur hauteur. Vous venez de mentionner la première cellule, mais je suppose que vous voulez être capable de le faire pour n'importe quelle cellule lorsque vous cliquez dessus.

Le projet complet est disponible à github

.h

#import <UIKit/UIKit.h> 


@interface FirstViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> { 
    NSIndexPath *selectedIndexPath; 
    NSDictionary *articles; 
} 

@end 

.m

#import "FirstViewController.h" 
@implementation FirstViewController 
- (void)viewDidLoad { 
    [super viewDidLoad]; 
    selectedIndexPath = nil; 
    articles = [[NSDictionary dictionaryWithObject:[NSArray arrayWithObjects:@"one", @"two", @"three", 
                @"four", @"five", @"six", 
                @"seven", @"eight", @"nine", 
                @"ten", @"eleven", nil] 
       forKey:@"title"] retain]; 
} 
- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
} 

- (void)viewDidUnload { 

} 

- (void)dealloc { 
    [selectedIndexPath release]; 
    [articles release]; 
    [super dealloc]; 
} 

- (int)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    return [[articles allKeys] count]; 
} 

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 
{ 
    return [[articles allKeys] objectAtIndex : section]; 
} 

- (int)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section 
{ 
    id key = [[articles allKeys] objectAtIndex:section]; 
    return [[articles objectForKey : key] count]; 
} 

- (float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if ((selectedIndexPath != nil) && (selectedIndexPath.row == indexPath.row)) 
     return 80.0; 
    return 40.0; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString * MyIdentifier = @"MyIdentifier"; 
    UITableViewCell * cell = [self.tableView dequeueReusableCellWithIdentifier:MyIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease]; 
    } 
    id key = [[articles allKeys] objectAtIndex:indexPath.section]; 
    cell.textLabel.text = [[articles objectForKey:key] objectAtIndex:indexPath.row]; 
    return cell; 
} 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (selectedIndexPath == indexPath) { 
     selectedIndexPath = nil; 
    } else { 
     selectedIndexPath = indexPath; 
    } 
    [self.tableView deselectRowAtIndexPath : indexPath animated : NO]; 
    [tableView beginUpdates]; 
    [tableView endUpdates]; 
} 

@end 

Ce code est assez rude, comme je viens extrait à partir d'un projet dans mon très premiers iPhone-jours. c'est-à-dire que des propriétés sont manquantes.