相关疑难解决方法(0)

向"静态单元"UITableView添加未知行数

我在Interface Builder中创建了一个静态表,其中包含6个部分,所有部分都有不同的行数.我现在想要添加具有不同行数的第7个部分.

首先,一旦我取消注释Xcode插入的标准表委托方法,我就会在self.tableView.tableHeaderView = containerView中崩溃; 我在表格中添加了一个标题.

更重要的是,我正在使用以下代码崩溃

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 7;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section==6) {
        return 4;
    } else {
        return [super tableView:tableView numberOfRowsInSection:section];
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{/*
    if (indexPath.section == 6) {
        static NSString *CellIdentifier = @"cellWireless";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        // Configure the cell...

        return cell;
    }*/
    return [super tableView:tableView cellForRowAtIndexPath:indexPath];
}
Run Code Online (Sandbox Code Playgroud)

如何正确地保留现有部分,但添加一个带有几个单元格的部分?

xcode cocoa-touch objective-c uitableview

39
推荐指数
4
解决办法
2万
查看次数

标签 统计

cocoa-touch ×1

objective-c ×1

uitableview ×1

xcode ×1