Iphone 显示重复值的表视图

Iphone 显示重复值的表视图,iphone,Iphone,显示重复值的表视图。它叫 -(UITableViewCell *)tableView:(UITableView *) cellForRowAtIndexPath:(NSIndexPath *)indexPath { } 方法两次。为什么会这样?实际显示数组值的表视图。使用NSSet方法避免重复值。NSArray而不是NSMutableArray。你可以用 [values setArray:[[NSSet setWithArray:values] allObjects]]; 或 你们

显示重复值的表视图。它叫

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

方法两次。为什么会这样?实际显示数组值的表视图。

使用NSSet方法避免重复值。NSArray而不是NSMutableArray。你可以用

   [values setArray:[[NSSet setWithArray:values] allObjects]]; 


你们有多少部分?也许这就是问题所在(例如,有两个部分,因此每个部分调用一次方法),您是否检查了表数组值?如果没有,请先记录阵列。
 NSMutableArray* uniqueValues = [[NSMutableArray alloc] init]; 
 for(id e in Values)
 {
    if(![uniqueValues containsObject:e])
    {
       [uniqueValues addObject:e];
    }
}