Ios 在tableview中添加单元格数组时查看最后一个单元格

Ios 在tableview中添加单元格数组时查看最后一个单元格,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我需要在tableview单元格中显示最后一条单元格记录。每次我都会在表视图中添加新数组。之后,我将重新加载tableview单元格。现在显示第一个单元格的记录。任何人请告诉我如何显示最后的细胞 // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

我需要在tableview单元格中显示最后一条单元格记录。每次我都会在表视图中添加新数组。之后,我将重新加载tableview单元格。现在显示第一个单元格的记录。任何人请告诉我如何显示最后的细胞

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {


static NSString *CellIdentifier = @"TrackDataTimeCell";
TrackDataTimeCell *cell = (TrackDataTimeCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
    @autoreleasepool {
        [[NSBundle mainBundle] loadNibNamed:@"TrackDataTimeCell" owner:self options:nil];
        cell = (TrackDataTimeCell *) cellChallengeFriends;
        cellChallengeFriends = nil;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
}

if (!cell) {
    cell =(TrackDataTimeCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];


    UIActivityIndicatorView *activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    cell.accessoryView = activityIndicatorView;

}
NSArray *tableData = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto", nil];
NSArray *tableData1 = [NSArray arrayWithObjects:@"test1", @"test2", nil];


[cell.deleteButton  addTarget:self action:@selector(deleteButtonAction:) forControlEvents:UIControlEventTouchUpInside];
cell.deleteButton.tag = indexPath.row;


cell.nameList.text= [tableData objectAtIndex:indexPath.row];
cell.marklist.text= [tableData1 objectAtIndex:indexPath.row];


return cell;

}


- (IBAction)addBillingItems:(id)sender
 {

    rowVal=rowVal+1;
    [nameList addObject: self.codeAdd.text];
    [marklist addObject: selectDate];

    [tbl reloadData];

}
请查看下面的示例图像:


我有5个细胞。现在它显示了前四个。在我滚动之后,它显示5,但我希望第一次显示最后一个单元格。请帮助我

您必须将tableview框架设置得更少。如果您有iPhone tableview框架,则将框架设置为cgrectmake(0,0320430)。如果这不能解决您的问题,则添加uitableview:ViewForHeaderSection方法。只需添加uiview并将框架设置为cgrectmake(0,0320,1)。这将设置表格的边框并显示所有单元格。

您可以使用此选项自动滚动到最后插入的单元格

    CGPoint bottomOffset = CGPointMake(0, self.tableView.contentSize.height - self.tableView.bounds.size.height + 150);
    if ( bottomOffset.y > 0 ) {
        [self.tableView setContentOffset:bottomOffset animated:YES];
    }

150值用于在tableView中的单元格后添加额外空间。它是可选的,也就是说,如果您想在单元格后面留出更多空间,您可以使用它。您的问题有一个简单的解决方案。只需使用tableView的方法

    [tbl scrollToRowAtIndexPath:[NSIndexPath indexPathForRow: rowVal inSection:0]
                      atScrollPosition:UITableViewScrollPositionBottom
                              animated:YES];

只要在
[tbl reloadData]

@Ahamed:我还有一个帮助want@Ahamed:有一个文本框。它现在是只读的。这里我想要的意思是,只要单击该文本框,就会调用一个操作。要执行操作/选择器,请在文本框的单击上调用一个方法?ryt?@Ahamed:是的,在我通过单击按钮操作调用方法之前。现在我想在.h文件中单击UITextfiledTake
UITextFieldDelegate
时调用methodos,然后在.m文件的
viewDidLoad
textField.delegate=self
然后将此方法添加到.m文件
-(BOOL)textField shouldbeginediting:(UITextField*)textField{[self myMethod];返回YES;}