UIActionSheet implement scroll to row.


#pragma mark -
#pragma mark UIActionSheetDelegate
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

if (actionSheet == _sheetForPageSummary) {
if (buttonIndex < 0) {
return;
}
// temp fix for bottom button crash
if (buttonIndex == 3)
return;
if ([[self.rows objectAtIndex:buttonIndex] count] == 0 ) {
; // no rows, do nothing
} else if (buttonIndex < [self.sectionHeaders count]) {
NSIndexPath* destination = [NSIndexPath indexPathForRow:0 inSection:buttonIndex];
[self.tableView scrollToRowAtIndexPath:destination atScrollPosition:UITableViewScrollPositionTop animated:YES];
} else {
NSInteger sectionIndex = [self.sectionHeaders count] - 1;
NSInteger rowIndex = [[self.rows objectAtIndex:sectionIndex] count] - 1;
NSIndexPath* destination = [NSIndexPath indexPathForRow:rowIndex inSection:sectionIndex];
[self.tableView scrollToRowAtIndexPath:destination atScrollPosition:UITableViewScrollPositionBottom animated:YES];
}
}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s