我想使用IB在单独的.xib中创建自定义标题部分视图
但是在IB中我找不到组件UITableViewHeaderFooterView(类似于UITableViewCell)并为其分配重用
那么如何在自定义标题部分创建?
我创建了一个继承自UITableViewHeaderFooterView的MySection类创建.xib,MySection.xib注册xib以便重用单元格
问题是,如何使用initWitReuseIdentifier ....
我有一个xib文件UITableView,我想使用委托方法添加自定义节标题视图tableView:viewForHeaderInSection:.有没有可能设计它Interface Builder,然后以编程方式更改它的一些子视图的属性?
我UITableView有更多的章节标题,以便创建一个UIView在Interface Builder和返回这是行不通的,因为我不得不重复它,但没有做任何好的方法.归档和取消归档它不适用于UIImages所以UIImageViews会显示空白.
此外,我不想以编程方式创建它们,因为它们太复杂,结果代码很难读取和维护.
编辑1:这是我的tableView:viewForHeaderInSection:方法:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
if ([tableView.dataSource tableView:tableView numberOfRowsInSection:section] == 0) {
return nil;
}
CGSize headerSize = CGSizeMake(self.view.frame.size.width, 100);
/* wrapper */
UIView *wrapperView = [UIView viewWithSize:headerSize];
wrapperView.backgroundColor = [UIColor colorWithHexString:@"2670ce"];
/* title */
CGPoint titleMargin = CGPointMake(15, 8);
UILabel *titleLabel = [UILabel labelWithText:self.categoriesNames[section] andFrame:CGEasyRectMake(titleMargin, CGSizeMake(headerSize.width - titleMargin.x * 2, 20))]; …Run Code Online (Sandbox Code Playgroud)