Hello在我的应用程序中,我在uitableview中制作播放器列表,因为我在单元格中添加uitextfield,当我添加更多单元格时,我的单元格是uitxtfiel向下滚动而不可见如何执行此操作
#pragma mark button methods
-(void)addmethod:(id)sender{
if(txtnewplayer.text == NULL || [txtnewplayer.text isEqualToString:@""])
{
UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:nil
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];
}
}
答案 0 :(得分:2)
添加新行后,您可以在指定的索引路径处滚动行。
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];