【发布时间】:2014-01-11 14:35:23
【问题描述】:
我是 iPhone 开发的新手,我有一个问题,我的应用程序包含从按钮单击到 tableView 的导航(我使用故事板)。我创建了 custum 原型 cell,它的类和标识符。但是在我调试的方法中,它涉及到cell==nil 并抛出异常:
'NSInternalInconsistencyException', reason: '无法在包中加载NIB
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"transportTableCell";
CNTransportCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSLog(@"size of %d",transportArray.count);
cell.modelLabelView.text = @"sometext";
if(cell == nil){
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:
@"transportTableCell" owner: self ////options:nil];
cell = [nib objectAtIndex:0];
}
return cell;
}
通过点击导航到表格视图的代码:
- (IBAction)searchButtonClick:(id)sender {
CNJSONParser *parser = [[CNJSONParser alloc]init];
NSString *url = [parser getURL:@"43" :@"66"];
CNCarListWindowController *cars = [[CNCarListWindowController alloc]init];
cars.transportArray = [parser parseJSON:url];
[self.navigationController pushViewController:cars animated:TRUE];
}
【问题讨论】:
标签: ios iphone ios5 uitableview