2010-11-15 87 views
1

我使用表代表此代码 我的应用程序崩溃,如果某个应用程序没有崩溃然后当我滚动表,直到最后一行即langTable 我不能滚动表格iPhone应用程序崩溃时我滚动的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"); 
} 
} 

登录来就死机时间是

*** 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' 

哪些错误代码为

阿米特Battan

+0

检查你的阵列,它包含任何数据或不? – raaz 2010-11-15 09:24:14

+0

它的解决我已经给出了答案,为什么它崩溃的原因 – 2010-12-02 07:23:02

回答

0

我发现了错误的东西 其实我也在我的应用程序中使用UIScrollView,当表滚动结束然后scrollViewDidEndDecelerating方法调用,我用于UIScrollView。 作为UITableView的具有超一流的UIScrolView

阿米特Battan