0
votes

I am developing an app. in which there a i have scroll view. and i am taking 2 table view on scroll view.i want when i add cell in second table the keyboard up and the last cell on table view which one i create will show. I tried below code.but its not working for me. any one know how to this ?. My app have same functionality like as "keep safe" app in iTunes.

-(NSIndexPath *)lastIndexPath   
{

    NSInteger lastSectionIndex = MAX(0, [tvAlbumCell numberOfSections] - 1);
    NSInteger lastRowIndex = MAX(0, [tvAlbumCell numberOfRowsInSection:lastSectionIndex] - 1);

   return [NSIndexPath indexPathForRow:lastRowIndex inSection:lastSectionIndex];

}

-(void)goToBottom
{

     NSIndexPath *lastIndexPath = [self lastIndexPath];

    [tvAlbumCell scrollToRowAtIndexPath:lastIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
}
1

1 Answers

0
votes

Try following code in goToBottom method..

 CGPoint bottomOffset = CGPointMake(0, tvAlbumCell.contentSize.height - tvAlbumCell.bounds.size.height);
 [tvAlbumCell setContentOffset:bottomOffset animated:YES];