UITableView中的一些坑
2015-10-05 07:24
423 查看
// 注意1:如果想从Stroyboard中加载静态表格,必须把这两个方法实现去掉,否则显示不出来数据,且静态表格只能在UITableViewController中实现
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 0;
}
// 注意2: 要想实现下面的方法:即自定义头部视图,必须荣国heightForHeaderInSection方法计算头高,不然第0组将不显示头部视图
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if (section == 0)
return self.contentView;
else return
nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == 0) {
return
self.contentView.height;
}else{
return
sectionHeight;
}
}
// 注意3:要想实现组头悬停的效果,tableView的样式必须是plain样式,不能是分组样式
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 0;
}
// 注意2: 要想实现下面的方法:即自定义头部视图,必须荣国heightForHeaderInSection方法计算头高,不然第0组将不显示头部视图
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if (section == 0)
return self.contentView;
else return
nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == 0) {
return
self.contentView.height;
}else{
return
sectionHeight;
}
}
// 注意3:要想实现组头悬停的效果,tableView的样式必须是plain样式,不能是分组样式
相关文章推荐
- SpriteBuilder中音频波长超过Timeline结尾的情况
- SpriteBuilder中音频波长超过Timeline结尾的情况
- SpriteBuilder中音频波长超过Timeline结尾的情况
- 2015/10/4 iOS 笔记 细节 简单-代理过程 UITableView
- HDOJ 题目5496 Beauty of Sequence(数学)
- iOS UISwitch用法和示例
- hdu 5496 Beauty of Sequence bc#58 组合 离散化
- Android后台进程与UI进程的交互
- Fluent NHibernate关系映射
- POJ 题目1239 ||ZOJ 题目 1499 Increasing Sequences(正反两次DP)
- Android UI ActionBar功能-ActionBarSherlock 的使用
- Android UI ActionBar功能-ActionBarSherlock 的使用
- SynchronousQueue的简单应用
- iOS编程-------UIImageView、手势识别器UIGestureRecognizer
- Android UI ActionBar功能-ActionBarProvider的使用
- Android UI ActionBar功能-ActionBarProvider的使用
- Android UI ActionBar功能-自动隐藏 Action Bar
- Android UI ActionBar功能-自动隐藏 Action Bar
- iOS编程-------事件处理UIEvent / 触摸事件UITouch
- Android UI ActionBar功能-Action Bar 左上角的向上或返回按钮