Alo*_*lok 1 iphone objective-c uitableview
我正在动态创建UITableView.当表视图已从数组填充时,我想添加3个虚拟行.
我的情况是,当有足够的数据时UITableView,然后在空白文本的uitable虚拟行的底部.
这样即使有40条记录,通过向上滚动最后两行也是可见的.假设我的数组计数为14(这是动态/不总是14)那么我如何在索引路径14,15,16中添加三个空行并将其文本设置为:
cell.textlabel.text=@"";
你可以这样做.
如下所示,重新调整行数.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
return [array count]+2; 
}
之后在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;
}
试试这可能对你有帮助.
谢谢,MinuMaster.
| 归档时间: | 
 | 
| 查看次数: | 1556 次 | 
| 最近记录: |