【发布时间】:2013-01-25 11:36:06
【问题描述】:
我正在为包含UITableView 的iPad 开发一个应用程序。该应用程序在模拟器上运行良好,但在安装并第一次运行时会在设备上崩溃。当我第二次尝试运行该应用程序时,它工作正常。我无法弄清楚问题所在。
相同的代码在 iPhone 上运行良好,但在 iPad 上崩溃。
我正在为表格使用以下代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *MythoViewCellIdentifier = @"MythoViewCellIdentifier ";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:MythoViewCellIdentifier];
if (cell==nil)
{
cell=[[[UITableViewCell alloc] initWithFrame:CGRectZero] autorelease];
}
[self getMythoData];
UIImageView *imgLogo =[[UIImageView alloc] initWithFrame:CGRectMake(-1,0,37,35)];
imgLogo.backgroundColor =[UIColor clearColor];
imgLogo.image=[UIImage imageNamed:@"bullet_swastik.png"];
[cell.contentView addSubview:imgLogo];
UITextView *txtDetails =[[UITextView alloc] initWithFrame:CGRectMake(37,34,740,200)];
txtDetails.backgroundColor =[UIColor clearColor];
txtDetails.editable=NO;
txtDetails.font=[UIFont systemFontOfSize:25.0];
[cell.contentView addSubview:txtDetails];
// adding details to the cell
txtDetails.text = [NSString stringWithFormat:@"%@",[FinalmythoData objectAtIndex:indexPath.row]];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[txtDetails release];
return cell;
}
I'm getting the following error
Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes:
KERN_INVALID_ADDRESS at 0x00000000 Crashed Thread: 0
Thanks
【问题讨论】:
-
它到底在哪里崩溃了?
-
哪个行会崩溃?调试器应该能够告诉你。如果调试器没有告诉你,你怎么知道它在上面的代码中?
-
因为应用程序在包含表格的地方崩溃。不包含表格的视图工作正常
-
数组计数即[FinalmythoData count];
标签: ipad uitableview ios4