【发布时间】:2015-07-26 06:18:53
【问题描述】:
我在ViewDidLoad 中构建了一个UITableView,如下所示:
- (void)viewDidLoad
{
CGSize viewSize = self.view.frame.size;
mainScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 35, viewSize.width, viewSize.height -149)];
[mainScroll setPagingEnabled:YES];
[mainScroll setShowsHorizontalScrollIndicator:NO];
[mainScroll setDelegate:self];
[mainScroll setTag:101010];
// #1
UIScrollView *scroll1 = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, viewSize.width, viewSize.height -149)];
UITableView *table101 = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, viewSize.width, viewSize.height -149) style:UITableViewStylePlain];
[table101 setDataSource:self];
[table101 setDelegate:self];
[table101 setBackgroundColor:[UIColor clearColor]];
[table101 setTag:101];
[table101 setSeparatorStyle:UITableViewCellSeparatorStyleNone];
[scroll1 addSubview:table101];
// #2
UIScrollView *scroll2 = [[UIScrollView alloc] initWithFrame:CGRectMake(viewSize.width, 0, viewSize.width, viewSize.height -149)];
UITableView *table102 = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, viewSize.width, viewSize.height -149) style:UITableViewStylePlain];
[table102 setDataSource:self];
[table102 setDelegate:self];
[table102 setBackgroundColor:[UIColor clearColor]];
[table102 setTag:102];
[table102 setSeparatorStyle:UITableViewCellSeparatorStyleNone];
[scroll2 addSubview:table102];
[mainScroll addSubview:scroll1];
[mainScroll addSubview:scroll2];
[mainScroll setContentSize:CGSizeMake(viewSize.width *2, viewSize.height -149)];
}
在TableViewCell我用这个:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
[cell setSeparatorInset:UIEdgeInsetsMake(0, 15, 0, 15)];
}
NSMutableArray *mutableArray;
if (tableView.tag == 101) {
mutableArray = self.itemsInTable_Molhaq;
} else if (tableView.tag == 102) {
mutableArray = self.itemsInTable_Ziyarah;
}
NSString *labelString = [[mutableArray objectAtIndex:indexPath.row] objectForKey:@"Title"];
NSInteger indentLevel = [[[mutableArray objectAtIndex:indexPath.row] objectForKey:@"Level"] intValue];
[cell.textLabel setAttributedText:[self attributeString:labelString indentLevel:indentLevel]];
return cell;
}
一切正常,但 Xcode 向我展示了这一点:
Unsupported configuration prototype table cells must have reuse identifiers
我错过了什么?我能得到一些帮助吗?
【问题讨论】:
-
这是情节提要编辑器的警告。检查您的 *.storyboard 文件和 this
-
可能是您在情节提要上使用 tableview。根据此代码,它不会给出此错误。
标签: objective-c xcode uitableview