I have a UITableView with a refresh button in toolbar.
If the TableView is stopped and I press refresh button calling reloadData
everything work fine.
But if I'm scrolling the tableview and press refresh button before tableview stops, the app crashes with this message:
-[NSMutableArray objectAtIndex:]: index 31 beyond bounds for empty array'
I think that with the scroll, 开发者_JS百科app is trying build cell reading a array that reloadData
cleared.
I'm trying to stop the scroll before reloadData
, but it does not work.
Any idea?
This is clearly not a solution to this problem, as you have not posted any code !
But, I would like to know why you would want to refresh the data while scrolling ? In the usability perspective, I do not think the users would do that either. I am guessing you are just testing the view with certain cases so that your app does not crash !
I would suggest that you make the UIButton
inactive when it's scrolling while the tableView is being scrolled.
myButton.enabled = NO;
// after scrolling you can set it to YES.
I really do not believe that users would want to refresh the table while the tableView
is scrolling, and if they press it accidentally, I think that little piece of code would fix the issue.
精彩评论