2010-07-16 4 views
2

pour cette raison que UITableView se bloque et il semble que l'UITableView est incapable d'afficher le secondString pour une raison quelconque mais je ne sais pas pourquoi ... s'il vous plaît aidez-moi ici parce que je ne sais pas ce que je pourrais être mal faire ..... Merci !!TableView se bloque

#import "SettingsView.h" 

@implementation SettingsView 

- (void)viewWillAppear:(BOOL)animated { 

    [super viewWillAppear:animated]; 
    transmissionSetup = [[TransmissionSetupViewController alloc]  initWithNibName:@"TransmissionSetupViewController" bundle:nil]; 
    transmissionSetup.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
    NSLog(@"%i", [self getMinutes]); 
    [self setSeconds:10]; 
    secondsString = [NSString stringWithFormat:@"%i", [self getSeconds]]; 
    [self.tableView reloadData]; 
} 

#pragma mark Table view methods 

// 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:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease]; 
    } 

    if (indexPath.section == 0) { 
     cell.textLabel.text = @"Every:"; 
     cell.detailTextLabel.text = secondsString; 
    } 
    // Set up the cell... 

    return cell; 
} 

@end 
+0

Quelle erreur voyez-vous dans la console? –

+0

2010-07-16 14: 16: 28.864 Navex [31130: 207] 0 Signal de programme reçu: "EXC_BAD_ACCESS". –

+0

J'ai enlevé des parties de code qui ne sont pas pertinentes à votre problème - s'il vous plaît essayez d'éviter d'envoyer du code inutile afin de vous aider – Vladimir

Répondre

1

INITIALISATION votre secondString avec la chaîne autoreleased - il est donc pas garanti que ce sera valable en dehors de la portée actuelle. Vous devez le conserver lors de l'initialisation (et ne pas oublier de le sortir plus tard)

Je vous conseille de jeter un oeil à l'objectif-c properties pour accéder aux ivars.

+0

je l'ai initialisé dans mon fichier d'entête comme ceci: NSString * secondsSTring ; comment puis-je le conserver lors de l'initialisation? –

+0

bien je l'ai eue merci beaucoup !!! –

0
// try this 
- (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]; 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; 
} 

if (indexPath.section == 0) { 
    cell.textLabel.text = @"Every:"; 
    cell.detailTextLabel.text = secondsString; 
} 
// Set up the cell... 

return cell; 
}