tableview设置header
2015-09-21 13:09
274 查看
1,在为uitableview设置分区标题时,需要用到两个方法。如下
#pragma mark setTitle
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == 0) {
return 50;
}
return 30;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
CGRect frameRect = CGRectMake(0, 0, 100, 40);
UILabel *label = [[[UILabel alloc] initWithFrame:frameRect] autorelease];
label.text=@"myTitle";
return label;
}
其中title若返回label时,一定要制定label的大小,不然显示不出来,因为label默认的大小是0.
#pragma mark setTitle
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == 0) {
return 50;
}
return 30;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
CGRect frameRect = CGRectMake(0, 0, 100, 40);
UILabel *label = [[[UILabel alloc] initWithFrame:frameRect] autorelease];
label.text=@"myTitle";
return label;
}
其中title若返回label时,一定要制定label的大小,不然显示不出来,因为label默认的大小是0.
相关文章推荐
- android权限大全
- AJAX解析
- TCP/IP 协议栈及 OSI 参考模型详解
- 理解RESTful架构
- 阿里云服务器或者其他网站绑定域名方法
- 记2015年的腾讯校招经历——状态篇
- Junit多线程测试
- C语言打印100—200之间的素数
- android仿音乐引用锁屏切换音乐歌曲壁纸
- 复杂链表的复制
- Cocos2d-x 2.2.3 Android配置
- hdu1532&&poj1273 最大流
- Dialog与FragmentDialog源代码分析
- NDK 在 Android studio如何使用(Android studio NDK)
- Win7 下,离线安装 Android Studio 1.0.1 的方法
- 关于 IT 系统可用性的一个粗略模型
- mybatis在xml文件大于号小于号的写法
- 学习数据结构的方法
- 转化为json字符串
- 安装laravel 的两种方式