误差的UITableView iphone

问题描述:

我有一个UITableView与行误差的UITableView iphone

-[self.friendsPhotoArray count]+1 

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

} 

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

谢谢。

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

- (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 
     } 
    } 
+0

没有我的问题是,对于所有其他行,我需要在didSelect执行的东西,但如果行变为[self.friendsPhotoArray计数]应该进行什么+1 – Papu 2011-05-18 10:32:50

在你cellForRowAtIndexPath方法只是把下面的检查:

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

[cell setUserInteractionEnabled:NO]; 

} 
+0

什么是LAST_ELEMENT? – Papu 2011-05-18 10:33:44

+0

它是您最后一个元素的索引。从你给出的代码看来,[self.friendsPhotoArray count] +1。因此,用它替换LAST_ELEMENT并尝试。 – 2011-05-18 10:35:43

+0

我编辑了答案。只需检查 – 2011-05-18 10:46:54

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

使其为2节和尝试... resuable可能会创造问题atlast有时.. 使您需要选择一个部分和另一个部分为非选择

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

    [cell setUserInteractionEnabled:NO]; 

} 

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

{ 

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