I've tried:
- (IBAction)openSearch {
[tblSimpleTable scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
[searchBar becomeFirstResponder];
}
and
- (IBAction)openSearch {
[self.tblSimpleTable scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
[searchBar becomeFirstResponder];
}
to get the table to scroll to the top. Both work when the table is only slightly scrolled away from the top but otherwise crashes with a "beyond bounds" error.
Any ideas. I am fairly new to this. Thanks.
--Edit--
Thanks for the feedback. Here's the precise error
2010-02-15 00:49:02.010 MyApp [2935:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray objectAtIndex:]: index (0) beyond bounds (0)'
2010-02-15 00:49:02.016 MyApp [2935:207] Stack: (
861696817,
860329709,
861252493,
861252395,
845801683,
845954223,
30161,
835250561,
835249847,
834989551,
834983899,
834971003,
805539851,
805539363,
805538115,
805537449,
805560369,
861158231,
861448761,
861447005,
861059891,
861060063,
834770799,
834765939,
10065,
9980
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
I don't get this problem when I scroll manually. The table is populated from an NSMutableArray. Does this help at all?