开发者

'ScrollToRowAtIndexPath' method does not work for 'iPad 3.2 Simulator'

开发者 https://www.devze.com 2023-03-11 09:32 出处:网络
For a part of my app, I require the table view to scroll to the first row again. I used the following code.

For a part of my app, I require the table view to scroll to the first row again. I used the following code.

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 
                                            inSection:0];
[self.tableView scrollToRowAtIndexPath:indexPath 
                      atScrollPosition:UITableViewScrollPositionTop 
                              animated:NO];

I tested the app on both the 'iPad 4.2 Simulator' and 'iPad 4.3 Simulator' and they worked fine. However the app crashed when I switched to 'iPad 3.2 Simulator' with the f开发者_高级运维ollowing error

* Terminating app due to uncaught exception 'NSRangeException', reason: '-[UITableView scrollToRowAtIndexPath:atScrollPosition:animated:]: section (0) beyond bounds (0).'

What am I doing wrong here? Also why does it work only for iPad 4.2 and 4.3 simulators but not the 3.2 one? I checked and understand that the scrollToRowAtIndexPath: method is available for iOS (2.0 and later).

0

精彩评论

暂无评论...
验证码 换一张
取 消