关于UITableView的经验教训

2016-08-08  本文已影响35人  健尐

改UITableViewCell的选中状态

1. 以为设置UITableViewCell的selected属性为True就等于选中
2. 需要用-selectRowAtIndexPath:animated:scrollPosition:方法才能达到选中效果

-selectRowAtIndexPath:animated:scrollPosition:方法(选中行)

1. 会令UITableViewCell为选中状态
2. 不会调用UITableViewDelegate的-(void)tableView:didSelectRowAtIndexPath:方法

-deselectRowAtIndexPath:animated:方法(未选中行)

1. 会令UITableViewCell为未选中状态
2. 不会调用UITableViewDelegate的-(void)tableView:didDeselectRowAtIndexPath:方法

-dequeueReusableCellWithIdentifier:(Cell重用)

1. 会在自动释放池获取UITableViewCell,样式是修改后的,不是init样式
2. 需要重新赋值修改样式

-dequeueReusableHeaderFooterViewWithIdentifier:(分组头尾部视图重用)

1. 受-reloadData方法影响,失去重用功能,要到iOS9版本苹果才更正
2. 貌似在iOS9以下的作用不大,兼容iOS9以下建议不用
上一篇下一篇

猜你喜欢

热点阅读