Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 将新的自定义单元格添加到UITableView的顶部_Ios_Iphone_Uitableview - Fatal编程技术网

Ios 将新的自定义单元格添加到UITableView的顶部

Ios 将新的自定义单元格添加到UITableView的顶部,ios,iphone,uitableview,Ios,Iphone,Uitableview,我尝试了更多的时间来搜索,但结果不是我想要的。我有一个自定义单元格的UITableView。还有一个按钮可以向UITableView添加新单元格。我可以添加新的单元格,但它将被添加到tableview的底部。这就是为什么,我无法感觉单元格是否被添加。所以我需要在桌面视图的顶部添加单元格。请帮助我 而不是[self.firstArray addObject:@”“使用 [self.firstArray insertObject:@"" atIndex:0]; 在addnewmarkets:act

我尝试了更多的时间来搜索,但结果不是我想要的。我有一个自定义单元格的UITableView。还有一个按钮可以向UITableView添加新单元格。我可以添加新的单元格,但它将被添加到tableview的底部。这就是为什么,我无法感觉单元格是否被添加。所以我需要在桌面视图的顶部添加单元格。请帮助我


而不是
[self.firstArray addObject:@”“使用

[self.firstArray insertObject:@"" atIndex:0];
addnewmarkets:
action集合中

NSInteger row = 0; 
在表格顶部显示新行

因此,最后将使用
addNewComments
方法

-(IBAction)addnewRemarks:(id)sender
{
    NSInteger row = 0;
    NSInteger section = 0;
    [self.firstArray insertObject:@"" atIndex:row];
    NSIndexPath *myindexpath = [NSIndexPath indexPathForRow:row inSection:section];
    // [selectedarray addObject:myindexpath];
    [self.firstTableView beginUpdates];

    [self.firstTableView insertRowsAtIndexPaths:@[myindexpath] withRowAnimation:UITableViewRowAnimationTop];
    [self.firstTableView endUpdates];
}

在您的代码中
NSInteger行=[self.firstArray count]-1这意味着新项目将在最后一个索引中添加。

共享您尝试过的代码。代码仍然在末尾添加。还有其他方法吗?非常感谢。。你真的节省了我的时间。
-(IBAction)addnewRemarks:(id)sender
{
    NSInteger row = 0;
    NSInteger section = 0;
    [self.firstArray insertObject:@"" atIndex:row];
    NSIndexPath *myindexpath = [NSIndexPath indexPathForRow:row inSection:section];
    // [selectedarray addObject:myindexpath];
    [self.firstTableView beginUpdates];

    [self.firstTableView insertRowsAtIndexPaths:@[myindexpath] withRowAnimation:UITableViewRowAnimationTop];
    [self.firstTableView endUpdates];
}