UITableView的scrollToRowAtIndexPath:atScrollPosition:animated的崩溃
UITableView的scrollToRowAtIndexPath:atScrollPosition:animated的崩溃
[摘要:reason: '-[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:]: row (0) beyond bounds (0) for section (0). 那个毛病是传进的IndexPath已越界了。须要正在挪用之前到场判别语句,没有影响机能的情]
reason: '-[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:]: row (0) beyond bounds (0) for section (0).
这个错误是传入的IndexPath已经越界了。需要在调用之前加入判断语句,不影响性能的情况下,在调用之前要先reloadDate
代码示例:
@implementation UITableView(ScrollToTopOrBottom)
-(void)scrollToTopWithAnimated: (BOOL)animated{
if([selfnumberOfSections]>&&[selfnumberOfRowsInSection: ]>){
[selfscrollToRowAtIndexPath: [NSIndexPathindexPathForRow: 0inSection: ]atScrollPosition: UITableViewScrollPositionTopanimated: animated];
}
}
-(void)scrollToBottomWithAnimated: (BOOL)animated{
if([selfnumberOfSections]>){
NSIntegerlastSectionIndex=[selfnumberOfSections]-;
NSIntegerlastRowIndex=[selfnumberOfRowsInSection: lastSectionIndex ]-;
if(lastRowIndex>){
NSIndexPath*lastIndexPath=[NSIndexPathindexPathForRow: lastRowIndexinSection: lastSectionIndex];
[selfscrollToRowAtIndexPath: lastIndexPathatScrollPosition: UITableViewScrollPositionBottomanimated: animated];
}
}
}@end
UITableView的scrollToRowAtIndexPath:atScrollPosition:animated的崩溃的更多相关文章
- scrollToItemAtIndexPath: atScrollPosition: animated:
oh my god 今天死在scrollToItemAtIndexPath: atScrollPosition: animated:方法上面,scrollPosition这个参数控制cell具体停留在 ...
- (转)A drop-in universal solution for moving text fields out of the way of the keyboard
There are a hundred and one proposed solutions out there for how to move UITextField andUITextView o ...
- UIScrollView 代理方法
在使用UIScrollView和它的子类UITableView时,有时需要在不同操作状态下,做不同的响应. 如何截获这些状态,如正在滚动,滚动停止等,使用UIScrollViewDelegate_Pr ...
- 二、UITableView和它的亲戚们
. UITableView 参考: https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITableView ...
- UITableView使用指南
本文转载至 http://blog.csdn.net/yu0089/article/details/8227402 一.概述 UITableView是iOS开发比不可少也是最重要的一个控件类.可以说任 ...
- iOS键盘覆盖输入框的处理.doc
在一个多项输入界面上,会有多个UITextfield类型的输入框.为了滚动方面,我们会将他们一一添加到UITableView的cell中,从而组成一个可以上下滑动的数据输入界面. 但是字符输入是通过系 ...
- Table View Programming Guide for iOS---(七)---Managing Selections
Managing Selections 管理选择 When users tap a row of a table view, usually something happens as a result ...
- IOS开发之UIScrollVIew运用
UIScrollView可以实现在一个界面看到所有内容,同时也不需要担心所显示的内容超出屏幕的大小,当超出之后可以翻阅至下一页浏览. #pragma mark - UIScrollViewDelega ...
- UITableView的编辑模式
UITableView可以分普通模式和Editing模式两种,这里我们着重讨论Editing模式,Editing模式中又分三种操作:Insert.Delete. Reallocted.Insert和D ...
随机推荐
- mysql基础面试
php面试题之五--MySQL数据库(基础部分) 五.MySQL数据库 mysql_num_rows() mysql_affected_rows() 这两个函数都作用于 mysql_query($qu ...
- expert C Programing notes
1.寻常算术转换 在运算中 如果其中一个操作数是long double 则另一个转为long double,其次 如果有一个为double 则另一个转为double,再次 float . unsign ...
- CentOS 6.5 安装nginx 1.6.3
使用epel [root@nginx /]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo ...
- Code First06---CodeFirst中的一对多关系
本章我将介绍Code First将类之间的引用关系映射为数据表之间的一对多关系的默认规则.主要包含以下两部分内容: 1.Code First将类之间的引用关系映射为数据表之间一对多关系的默认规则. 2 ...
- BZOJ2631——tree
1.题目大意:bzoj1798的lct版本 2.分析:这个把线段树改成splay就好 #include <stack> #include <cstdio> #include & ...
- [转载]Web 研发模式演变
原文链接:https://github.com/lifesinger/blog/issues/184 前不久徐飞写了一篇很好的文章:Web 应用的组件化开发.本文尝试从历史发展角度,说说各种研发模式的 ...
- php curl 实例+详解
直接上实例 <?php //创建一个新cURL资源 $ch = curl_init(); //用于中文等特殊字符的url转码 $aurl = urlencode($address); $url= ...
- How to tile small texture image onto page as its background
You don’t need to set a big size image as the background of pages if the image is texture or uniform ...
- 跨域解决方案二:使用JSONP实现跨域
跨域的实现方式有多种,除了 上篇文章 提到的CORS外,常见的还有JSONP.HTML5.Flash.iframe.xhr2等. 这篇文章对JSONP的跨域原理进行了探索,并将我的心得记录在这里和大家 ...
- 浅析mongoEngine的document对象
引言: from mongoengine import * connect('local')class Test(Document): name=StringField(max_length=32) ...