2010-11-15 7 views
1

J'utilise ce code pour les délégués de table plantage de mon application lorsque je fais défiler la table jusqu'à la dernière ligne c.-à-langTable si quelque temps l'application ne se effondre alors je ne suis pas en mesure de faire défiler la tableIphone application se bloque lorsque je fais défiler la UITableView

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
NSLog(@"Test 0"); 
if (tableView==langTable) { 
    NSLog(@"Test 0 complete lang table %d",[langArray count]); 
    return [langArray count]; 
}else if (tableView==gameTypeTable) { 
    NSLog(@"Test 0 complete gametype %d",[gameTypeArray count]); 
    return [gameTypeArray count]; 
} 
NSLog(@"Test 0 complete 0"); 
return 0; 
} 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *CellIdentifier = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 
} 

// Set up the cell... 
NSString *cellValue; 
if (tableView==langTable) { 
    NSLog(@"1Test 1...%d-%@",indexPath.row,[[langArray objectAtIndex:indexPath.row] objectForKey:@"lang_caption"]); 
    cellValue = [[langArray objectAtIndex:indexPath.row] objectForKey:@"lang_caption"]; 
}else if (tableView==gameTypeTable) { 
    NSLog(@"2Test 1...%d-%@",indexPath.row,[[gameTypeArray objectAtIndex:indexPath.row] objectForKey:@"caption"]); 
    cellValue = [[gameTypeArray objectAtIndex:indexPath.row] objectForKey:@"caption"]; 
}else { 
    NSLog(@"3Test 1...%d-kuch.ni.hai",indexPath.row); 
    cellValue = @""; 
} 
cell.text = cellValue; 
NSLog(@"Text 1 Complete"); 
return cell; 
} 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 

NSLog(@"select"); 
if (tableView==langTable) { 
    NSLog(@"langTable1"); 
    functionality.gameLang = indexPath.row; 
    NSLog(@"langTable2"); 
}else if (tableView==gameTypeTable) { 
    NSLog(@"gameTypeTable1"); 
    functionality.gameType = indexPath.row; 
    NSLog(@"gameTypeTable2"); 
} 
} 

Log est le temps de l'accident sont

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array' 
*** Call stack at first throw: 
(
0 CoreFoundation      0x026a7919 __exceptionPreprocess + 185 
1 libobjc.A.dylib      0x027f55de objc_exception_throw + 47 
2 CoreFoundation      0x0269d465 -[__NSArrayM objectAtIndex:] + 261 
3 SensoryStimulation     0x00006fe5 -[Functionality onPageChange:] + 829 
4 SensoryStimulation     0x000029cc -[SensoryStimulationViewController scrollViewDidEndDecelerating:] + 126 
5 UIKit        0x0030b0ad -[UIScrollView(UIScrollViewInternal) _stopScrollDecelerationNotify:] + 322 
6 UIKit        0x00315fbb -[UIScrollView(Static) _smoothScroll:] + 3999 
7 UIKit        0x003337b8 -[UITableView(_UITableViewPrivate) _smoothScroll:] + 75 
8 UIKit        0x00301e88 ScrollerHeartbeatCallback + 129 
9 GraphicsServices     0x02e9556d HeartbeatTimerCallback + 35 
10 CoreFoundation      0x02688d43 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19 
11 CoreFoundation      0x0268a384 __CFRunLoopDoTimer + 1364 
12 CoreFoundation      0x025e6d09 __CFRunLoopRun + 1817 
13 CoreFoundation      0x025e6280 CFRunLoopRunSpecific + 208 
14 CoreFoundation      0x025e61a1 CFRunLoopRunInMode + 97 
15 GraphicsServices     0x02e922c8 GSEventRunModal + 217 
16 GraphicsServices     0x02e9238d GSEventRun + 115 
17 UIKit        0x002d5b58 UIApplicationMain + 1160 
18 SensoryStimulation     0x000027aa main + 84 
19 SensoryStimulation     0x0000272a start + 54 
) 
terminate called after throwing an instance of 'NSException' 

Quel est le problème avec le code

Amit Battan

+0

Vérifiez votre tableau, il ne contient aucune donnée ou non? – raaz

+0

son résolu j'ai donné la raison en réponse pourquoi il se bloque –

Répondre

0

J'ai trouvé la mauvaise chose En fait, j'utilise aussi un UIScrollView dans mon application, lorsque le défilement du tableau se termine, puis les appels de méthode scrollViewDidEndDecelerating que j'ai utilisés pour le UIScrollView. Comme UITableView a super classe UIScrolView

Amit Battan

Questions connexes