【发布时间】:2015-06-08 11:45:40
【问题描述】:
我正在使用 2 个表格视图。我正在使用标签使用这两个表。在父 TableView 中有 3 个单元格。在父表的第三个单元格中添加了另一个表。我仔细检查了整个代码,但找不到错误。但是我收到这个错误,我很困惑为什么?我不知道问题出在哪里。我的应用程序崩溃了。这是我的崩溃代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
switch (tableView.tag)
{
case kTagBaseTableView:
{
if (indexPath.row == 0)
{
static NSString *simpleTableIdentifier = @"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.backgroundColor = [UIColor purpleColor];
//return cell;
}
if (indexPath.row == 1)
{
static NSString *simpleTableIdentifier = @"Cell1";
cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
self.scrollView1 = (UIScrollView *)[cell viewWithTag:6];
self.customStoryboardPageControl = (TAPageControl *)[cell viewWithTag:7];
self.scrollView1 = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, cell.frame.size.height+55)];
[self.scrollView1 setContentOffset:CGPointZero animated:NO];
self.scrollView1.delegate = self;
self.customStoryboardPageControl = [[TAPageControl alloc] init];
self.customStoryboardPageControl.frame = CGRectMake(10, 80, tableView.frame.size.width, 30);
self.customStoryboardPageControl.numberOfPages = self.imagesData.count;
[[cell contentView] addSubview:self.scrollView1];
[[cell contentView] addSubview:self.customStoryboardPageControl];
[self setupScrollViewImages];
cell.backgroundColor = [UIColor yellowColor];
//return cell;
}
}
case kTagInnerTableView:
{
ORGContainerCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ORGContainerCell"];
cell.backgroundColor = [UIColor greenColor];
[cell setCollectionData:self.sampleData];
[cell setCollectionImage:self.sampleImage];
cell.textLabel.text = @"Horizontal TableView";
cell.backgroundColor = [UIColor redColor];
//return cell;
}
default:
break;
}
return cell;
}
【问题讨论】:
-
你检查过你的表格标签吗?如果在这两种情况下都调用它。
-
是的。我仔细检查了我的表格标签。
标签: ios objective-c uitableview storyboard