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 ...
随机推荐
- SQL双重游标(双重循环)--笔记
declare )='', )='', )='' --创建游标 declare @cursor cursor --设定游标欲操作的数据集 set @cursor=cursor for select s ...
- 阻止点击<a>标签链接跳转
我们常用的在a标签中有点击事件(<a href="地址">链接</a>),其中“href”参数只要不为空,点击该链接时,页面会自动跳转:如果指定的“hr ...
- ZJOI2014 2048
Description 提交答案题,写个2048 AI 告诉你随机数生成方式. Sol xjblg+A*. 首先我写了个模拟,2048. 然后自己YY就可以啦...各种乱搞... 因为随机数,一个最好 ...
- PHP环境搭建——Apache、Mysql、PHP单独安装(for Windows)
提示: 安装之前先要安装vcredist_x86.exe或vcredist_x64.exe(vc6,vc9,vc11等,和下面对应). 确保apache和php是用同样版本的编译器编译出来的,如果是v ...
- hustoj1353 节点选择 树形dp
1353: 结点选择 时间限制: 1 Sec 内存限制: 128 MB提交: 6 解决: 2[提交][状态][讨论版] 题目描述 问题描述 有一棵 n 个节点的树,树上每个节点都有一个正整数权值. ...
- zabbix之MySQL数据库的安装
转载自:http://www.ttlsa.com/mysql/install-mysql5_6/ 启动MySQL并制定套接字 mysql -u user -ppassword -S 指定socket路 ...
- Selenium Webdriver元素定位的常用方式
单选框.复选框.文本框和密码框的元素标签都是input,此时单靠tagName无法准确地得到我们想要的元素,需要结合type属性才能过滤出我们要的元素.示例代码如下: public class Sea ...
- python协程
http://bingotree.cn/?p=63 协程与yield的介绍,轻松搞笑. http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d ...
- centos mysql 大量数据导入时1153 错误:1153 - Got a packet bigger than 'max_allowed_packet' bytes
参考:http://stackoverflow.com/questions/93128/mysql-error-1153-got-a-packet-bigger-than-max-allowed-pa ...
- Quartz表达式详解(转载)
1. CronTrigger时间格式配置说明 CronTrigger配置格式: 格式: [秒] [分] [小时] [日] [月] [周] [年] 序号 说明 是否必填 允许填写的值 允许的通配符 ...