开发者

UITableview scroll to top for two cell

Hello In my application i make player list in uitableview for that i am add uitextfield in cell when i am add more cells then my cell that is take uitextfiel is scroll down and not visible how to do this

#pragma mark button methods
-(void)addmethod:(id)sender{

    if(txtnewplayer.text == NULL  || [txtnewplayer.text isEqualToString:@""])
    {
        UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:nil
         开发者_JAVA百科                                                 message:@"Please enter player name" 
                                                         delegate:self 
                                                cancelButtonTitle:@"OK" 
                                                otherButtonTitles:nil, nil];
        [myAlert show];
        [myAlert release];
    }
    else
    {

        NSInteger tid = ((UIControl *) sender).tag;
        NSIndexPath *topIndexPath;
        topIndexPath = [NSIndexPath indexPathForRow:tid inSection:0];
        [self.tableView selectRowAtIndexPath:topIndexPath animated:YES              scrollPosition:UITableViewScrollPositionTop];
     [appDelegate.PlayerLists addObject:txtnewplayer.text];
     [self.tableView reloadData]; 
    }
}


You can scroll row at your specified index path after new row added.

[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜