UITableView 右边索引第一个出现空白情况的解决办法
2013-05-05 02:45
375 查看
我们使用表格控件显示1-1000,由于表格太长,我们可能会参考电话本的索引功能,在右边显示1,100,200,300,400,...,1000,这样用户点击500,就能快速显示500.
也就是设置
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView 函数
和
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString
*)title atIndex:(NSInteger)index 函数
但我们点击第一个索引的时候,有时候会出现空白,表格滚动屏幕底部隐藏起来了,触摸一下屏幕,表格又出来了,解决办法就是判断如果是第一个索引,不要使用动画效果
NSIndexPath *indexPath =
nil;
if (iIndex < 1) { //第一个索引不能用动画效果
indexPath = [NSIndexPath
indexPathForRow:0
inSection:0];
[tableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionTop
animated:NO];
}else {
indexPath = [NSIndexPath
indexPathForRow:iIndex-1
inSection:0];
[tableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionTop
animated:YES];
}
也就是设置
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView 函数
和
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString
*)title atIndex:(NSInteger)index 函数
但我们点击第一个索引的时候,有时候会出现空白,表格滚动屏幕底部隐藏起来了,触摸一下屏幕,表格又出来了,解决办法就是判断如果是第一个索引,不要使用动画效果
NSIndexPath *indexPath =
nil;
if (iIndex < 1) { //第一个索引不能用动画效果
indexPath = [NSIndexPath
indexPathForRow:0
inSection:0];
[tableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionTop
animated:NO];
}else {
indexPath = [NSIndexPath
indexPathForRow:iIndex-1
inSection:0];
[tableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionTop
animated:YES];
}
相关文章推荐
- UITableView下拉 顶部出现64空白的Bug解决
- Android中 在显示ImageView时图片上面和下面都出现一段空白区间的解决办法
- UIScrollView上面放一个UIScrollView或者UITableView拖动时候 View出现一闪一闪解决办法
- iOS-tableview上方出现一段空白的原因及解决办法
- Android中 在显示ImageView时图片上面和下面都出现一段空白区间的解决办法
- Android中 在显示ImageView时图片上面和下面都出现一段空白区间的解决办法
- WebView通过URL加载H5界面出现空白的原因与解决办法
- Android--在显示ImageView时图片上面和下面都出现一段空白区间的解决办法
- tableView上出现空白的解决办法
- 【Android】在显示ImageView时图片上面和下面都出现一段空白区间的解决办法
- ios8 UITableView设置 setSeparatorInset UIEdgeInsetsZero不起作用的解决办法(去掉15px空白间距)
- Android中 在显示ImageView时图片上面和下面都出现一段空白区间的解决办法
- UITableView在约束正确设置的情况下出现顶部空白区域
- textView出现最后一行字体缺少一部分的情况解决办法
- ios8 UITableView设置 setSeparatorInset:UIEdgeInsetsZero不起作用的解决办法(去掉15px空白间距)
- 安装Linux 系统 分区时出现空闲空间不可用的情况解决办法
- UITableView与UIPageViewController的UIPanGestureRecognizer手势冲突解决办法
- iOS7适配问题 UITableView上方出现空白
- 浏览器预览PHP文件时顶部出现空白影响布局分析原因及解决办法
- 适配iPhone6和6P UITableView分割线会闪动(拖动UITableView的时候,分割线 一会儿变粗一会儿变细)解决办法