首页 > 其他 > 详细

UITableView

时间:2014-06-29 21:50:40      阅读:536      评论:0      收藏:0      [点我收藏+]

1.如何设置tableview  每行之间的分割线

self.table.separatorStyle=UITableViewCellSeparatorStyleSingleLine;


2.如何让cell 能够响应 select,但是选中后的颜色又不发生改变呢,那么就设置

法一:完全不变色

cell.selectionStyle  =  UITableViewCellSelectionStyleNone;

法二:变下色马上恢复

[tableView deselectRowAtIndexPath:indexPath animated:NO];


3.如何获得 某一行的CELL对象

- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath;


4.如何获得 某一行的CELL对象

UITableViewCell *ta = [self.table cellForRowAtIndexPath:indexPath];


5.行缩进

-(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath{

    NSUInteger row = [indexPath row];

    return row;

}


6.TableView添加时最顶端有段空白,如何去掉最上面的那一段空白

 .pch文件中写一段宏

#define kNavigationBarFit(obj) [objsetEdgesForExtendedLayout:UIRectEdgeNone];\

[obj setExtendedLayoutIncludesOpaqueBars:NO];\

[obj       setModalPresentationCapturesStatusBarAppearance:NO];\

self.navigationController.navigationBar.translucent= NO;

在定义tableView时写上

[selfsetEdgesForExtendedLayout:UIRectEdgeNone];


7.怎么解决Cell重用问题

在重用前把cell里的子视图删了

    for (UIView *v in cell.contentView.subviews) {

        [v removeFromSuperview];

    }


8.设置索引,返回的是一个数组,如例子,返回0代表第一组的索引,1代表第二组索引,2待变第三组索引

-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView

{

    return @[@"0",@"1",@"2"];

}


UITableView,布布扣,bubuko.com

UITableView

原文:http://5828666.blog.51cto.com/5818666/1431963

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!