UITableView iphone出错

时间:2011-05-18 10:17:09

标签: iphone uitableview cell

我有UITableView

-[self.friendsPhotoArray count]+1

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [self.friendsPhotoArray count]+1;
    NSLog(@"array val%@",[self.friendsPhotoArray count]);

}

现在我想检查哪一行是最后一行并使其成为不可编辑的,即不执行 didSelect功能。有人可以帮忙吗?

感谢。

6 个答案:

答案 0 :(得分:1)

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
  if(indexPath.row==[array count]-1)
  {
    //Do Nothing
  }
  else 
  {
    //Do Whatever You Want
  }
}

答案 1 :(得分:0)

禁用表格视图最后一行的选择:

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

    // make the cell selection style none 
    }
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    // if the last row is selected do nothing.
       if(row!=count+1){
           // do functionality
       }
  }

答案 2 :(得分:0)

cellForRowAtIndexPath方法中,只需进行以下检查:

if (indexPath.row ==  [self.friendsPhotoArray count]+1) {

[cell setUserInteractionEnabled:NO];

}

答案 3 :(得分:0)

将它作为2个部分并尝试...可重用的有时可能会创建问题地图集。 制作一个你需要选择的部分,另一部分选择

答案 4 :(得分:0)

if (indexPath.row ==  [array count]+1) {

    [cell setUserInteractionEnabled:NO];

}

答案 5 :(得分:0)

-(UITableViewCellEditingStyle)tableView:(UITableView *)aTableView  editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath

{

    if (indexPath.row==yourarray.count-1)
    {
        return UITableViewCellEditingStyleNone;
    }
    else
    {
        return UITableViewCellEditingStyleDelete;
    }
}