UITableView的代理方法viewForHeaderInSection不执行的原因
2016-07-15 17:48
891 查看
有时候我们想自定义UITableView的headerView,于是重写代理方法:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
但是在运行程序的时候发现该方法不执行,这时我们还需要重写一个代理方法:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
这个方法是用来指定headerView的高度的。
当然,我们可以通过self.tableView.tableHeaderView = [[UIView alloc] init];这种方式来自定义headerView,但是这种方式会使tableView中所有的headerView都一样,如果我们想让每一组的headerView不一样只能使用代理方法。
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
但是在运行程序的时候发现该方法不执行,这时我们还需要重写一个代理方法:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
这个方法是用来指定headerView的高度的。
当然,我们可以通过self.tableView.tableHeaderView = [[UIView alloc] init];这种方式来自定义headerView,但是这种方式会使tableView中所有的headerView都一样,如果我们想让每一组的headerView不一样只能使用代理方法。
相关文章推荐
- IBM CleanQuest使用方法
- hdu 1159 Common Subsequence
- View requires API level 14 (current min is 8): <GridLayout>
- discuz X3.2 开启QQ互联后,点击登录以后报错:(1054) Unknown column 'conuintoken' in 'field list'
- Cf Round #361 (Div. 2) 689D. Friends and Subsequences
- UITableViewCell 中的单选控制 UITableViewCellAccessoryCheckmark
- org.openqa.selenium.remote.SessionNotFoundException: The FirefoxDriver cannot be used after quit() was called.
- Android进阶UI之使用TextInputLayout创建一个登陆界面
- UESTC149 解救小Q
- Druid 数据库用户密码加密 代码实现
- UI面板拖放
- UITableViewController类预置模板详解(部分一)
- HDU 1005 Number Sequence[数论]
- NSString之 doubleValue floatValue intValue integerValue longLongValue
- arm交叉编译器gnueabi、none-eabi、arm-eabi、gnueabihf、gnueabi区别
- UITextField 输入限制
- ubuntu bluetooth 配对过程
- easyUI 消息框的API
- POJ 3080 Blue Jeans
- UIView初始化