有没有办法使用故事板将静态表格视图单元格(静态内容)与动态表格视图单元格(原型内容)结合起来?
我建议您将表格视为动态表格,但在顶部包含您始终想要的单元格。在故事板中,放置一个UITableViewController
并让它使用动态表。添加任意数量UITableViewCell
根据需要将原型添加到表格中。比如说,每个静态单元格一个,一个代表可变单元格。
In your UITableViewDataSource
class:
#define NUMBER_OF_STATIC_CELLS 3
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.dynamicModel count] + NUMBER_OF_STATIC_CELLS;
}
进而
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row < NUMBER_OF_STATIC_CELLS) {
// dequeue and configure my static cell for indexPath.row
NSString *cellIdentifier = ... // id for one of my static cells
} else {
// normal dynamic logic here
NSString *cellIdentifier = @"DynamicCellID"
// dequeue and configure for [self.myDynamicModel objectAtIndex:indexPath.row]
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)