iphone是否有任何方法可以在所有动态数据填充之后在uitableview中添加带有@""的空白行:iphone

Alo*_*lok 1 iphone objective-c uitableview

我正在动态创建UITableView.当表视图已从数组填充时,我想添加3个虚拟行.

我的情况是,当有足够的数据时UITableView,然后在空白文本的uitable虚拟行的底部.

这样即使有40条记录,通过向上滚动最后两行也是可见的.假设我的数组计数为14(这是动态/不总是14)那么我如何在索引路径14,15,16中添加三个空行并将其文本设置为:

cell.textlabel.text=@"";
Run Code Online (Sandbox Code Playgroud)

Min*_*ter 7

你可以这样做.

如下所示,重新调整行数.

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
return [array count]+2; 
}
Run Code Online (Sandbox Code Playgroud)

之后在cellRowAtindexPath方法中管理它,如下所示:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
[tableView setPagingEnabled:NO];
//[tableView setSeparatorColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"longDotedLine.png"]]];

  if (indexPath.row < [array count]) {
      cell.textLabel.text = @"Test Data";
  } else {
      cell.textLabel.text = @"";
  }


return cell;

}
Run Code Online (Sandbox Code Playgroud)

试试这可能对你有帮助.

谢谢,MinuMaster.