簡體   English   中英

UITableview滾動到兩個單元格的頂部

[英]UITableview scroll to top for two cell

你好在我的應用程序中我在uitableview中制作播放器列表,因為我在單元格中添加uitextfield,當我添加更多單元格時,我的單元格是uitextfiel向下滾動而不可見如何執行此操作

#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]; 
    }
}

添加新行后,可以在指定的索引路徑處滾動行。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM