简体   繁体   English

uiscrollview故事板中的uitableview

[英]uitableview inside uiscrollview storyboard

So I have a UIScrollView in storyboard and a UITableView in storyboard as well. 所以我在情节UIScrollView中有一个UIScrollView在情节UIScrollView中也有一个UITableView The point is that I want to put inside the scrollview several instances of that UITableView . 关键是我想在滚动视图中放入该UITableView多个实例。 But I get an error 但我得到一个错误

unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard

So how to solve this problem? 那么如何解决这个问题呢?

Thanks in advance! 提前致谢!

Ok! 好! Here's my code: 这是我的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"DayCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    [self configerCell:cell atIndexPath:indexPath];

    return cell;
}

And I gave a cell an identifier in storyboard... 我在情节提要中给一个单元一个标识符...

That's how I add UITableView to UIScrollView: 这就是我将UITableView添加到UIScrollView的方法:

UITableViewController *tableView = [[UITableViewController alloc] initWithStyle:UITableViewStyleGrouped];
[self.mainScroll addSubview:tableView.view];

I think your tableview cell needs an identifier. 我认为您的tableview单元格需要一个标识符。 Try'n click on the table view cell and under the attributes inspector there is a field named Identifier . 尝试单击表格视图单元格,然后在属性检查器下方有一个名为Identifier的字段。 Check That! 检查一下!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM