在TableView中显示多个信标的问题

时间:2015-09-01 02:26:35

标签: ios objective-c uitableview ibeacon

我正在尝试在tableView中显示多个信标。每个信标的次要值,名称和图像存储在核心数据中。虽然信标的名称和图像正确地出现在tableView单元格中,但是接近总是更改为最近的信标。

我真的很感激帮助!

DisplayTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellID"];
Tag *tag = [self.tags objectAtIndex:indexPath.row];
cell.textLabel.text = @"";    

NSData *data = tag.image;
UIImage *image = [UIImage imageWithData:data];
cell.imageView.image = image; //BEACONS

if (self.tags.count > 0)
{        
    self.arrow.hidden = true;
    self.addLabel.hidden = true;    

    CLBeacon *beacon = [self.beacons objectAtIndex:indexPath.row];

    NSString *proximityLabel = @"";
    switch (beacon.proximity)
    {
        case CLProximityFar:
            proximityLabel = [NSString stringWithFormat:@"Your %@ is Far", tag.name];
            cell.backgroundColor = [UIColor colorWithRed:(255/255.0) green:(107/255.0) blue:(105/255.0) alpha:1];
            break;        
        case CLProximityNear:
            proximityLabel = [NSString stringWithFormat:@"Your %@ is Near", tag.name];
            cell.backgroundColor = [UIColor colorWithRed:(96/255.0) green:(102/255.0) blue:(232/255.0) alpha:1];
            break;
        case CLProximityImmediate:
            proximityLabel = [NSString stringWithFormat:@"Your %@ is Close", tag.name];
            cell.backgroundColor = [UIColor colorWithRed:(118/255.0) green:(225/255.0) blue:(167/255.0) alpha:1];
            break;            
        case CLProximityUnknown:
            proximityLabel = @"Fetching Location";
            cell.backgroundColor = [UIColor whiteColor];
            break;
    }

    cell.nameLabel.text = tag.name;    

    NSString *detailLabel = [NSString stringWithFormat:@"%@, Dist: %0.001f", proximityLabel, beacon.accuracy];
    cell.proxLabel.text = detailLabel;        

    self.tableView.hidden = false;
    self.mapView.hidden = false;
}

return cell;
} 

0 个答案:

没有答案