a7m*_*7md 3 objective-c uitableview ios7
我做了一个UITableView并设置了"委托"和"数据源",每次调用时reloadData,它都会进入方法:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [self.headersList count];
}
Run Code Online (Sandbox Code Playgroud)
方法:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
SectionInfo *headerInfo = (self.headerInfoArray)[section];
NSInteger numOfObjectsInSection = [[headerInfo.list objectsInList] count];
return headerInfo.open ? numOfObjectsInSection : 0;
}
Run Code Online (Sandbox Code Playgroud)
然后停下来!它没有进入ViewForHeaderInSection:方法.我也实现了这个方法:
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return SECTION_HEADER_HEIGHT;
}
Run Code Online (Sandbox Code Playgroud)
该viewForHeaderInSection方法:
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UISectionHeaderView *sectionHeaderView = [[UISectionHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, SECTION_HEADER_HEIGHT)];
SectionInfo *sectionInfo = (self.headerInfoArray)[section];
sectionHeaderView.open = sectionInfo.open;
sectionInfo.headerView = sectionHeaderView;
sectionHeaderView.titleLabel.text = [NSString stringWithFormat:@"%@ (%lu)",sectionInfo.list.title, (unsigned long)[sectionInfo.list.objectsInList count]];
sectionHeaderView.section = section;
sectionHeaderView.delegate = self;
return sectionHeaderView;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5395 次 |
| 最近记录: |