HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 通过Storyboard和新的Xib实现自定义表部分标题大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我做的:

我创建了一个自定义xib文件,它具有用于自定义表部分标题的小UIView.
分类自定义xib文件.

我想添加到tableView作为标题.我已经看了几个资源,但他们似乎是过时的或缺少信息.

查看文档,我看到一个引用添加一个自定义标题与以下说明:

当我将tableView添加到我的故事板视图中时,很容易在xcode中分配一个重用标识符.我甚至可以创建一个自定义单元格xib文件,并且它还有一个在xcode中重用标识符的位置.

当我为段标题创建自定义UIView时,它没有一个用于重用标识符的条目.没有这个,我不知道如何使用registerNib:forCellReusEIDentifier.

更多信息:
我有一个storyboard场景,里面有一个tableView. tableView是一个链接自定义类,tableView对象在父视图的ViewController文件中有一个插座.

父ViewController都是UITableViewDatasourceDelegate和UITableViewDelegate.再次,我能够实现没有问题的自定义单元格.除了标题,我甚至不能以任何方式修改标题.

我尝试调用方法[[self tableHeaderView] setBACkgroundColor:[UIColor clearColor]];从定制的tableView类,没有任何反应.我尝试在父ViewController类中使用这种方法,使用这样的插座名称
[[self.tabLeoutlet tableHeaderView] setBACkgroundColor:[UIColor clearColor]];

任何帮助将不胜感激.

编辑:(不能将背景改为透明)

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {

    HeaderView *headerView = [self.TableView dequeueReusableHeaderFooterViewWithIdentifier:@"tableHeader"];

    // Set BACkground color
    [[headerView contentView] setBACkgroundColor:[UIColor clearColor]];

    // Set Text
    headerView.headerLabel.text = [self.sectionArray objectATindex:section];

    return headerView;
}

解决方法

您不需要在xib中设置标识符 – 您只需要在注册时使用相同的标识符,并且当您将标题视图排队时.在viewDidLoad方法中,我注册了这样的视图:
[self.tableView registerNib:[UINib nibWithNibName:@"Header1" bundle:nil] forHeaderFooterViewReusEIDentifier:@"header1"];

然后,在委托方法中:

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *headerView = [self.tableView dequeueReusableHeaderFooterViewWithIdentifier:@"header1"];
    return headerView;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 100;
}

大佬总结

以上是大佬教程为你收集整理的ios – 通过Storyboard和新的Xib实现自定义表部分标题全部内容,希望文章能够帮你解决ios – 通过Storyboard和新的Xib实现自定义表部分标题所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。