// // RADetailMapCell.m // Apex And Drivers // // Created by Jack on 2018/9/4. // Copyright © 2018年 USAI. All rights reserved. // #import "RADetailMapCell.h" #import #import "RADetailMapModel.h" @interface RADetailMapCell () @property (strong, nonatomic) IBOutlet UILabel *titleLabel; //@property (strong, nonatomic) IBOutlet MKMapView *mapView; @property (strong, nonatomic) IBOutlet UITextView *valueLabel; @property (strong, nonatomic) IBOutlet UIButton *navigationBtn; @end @implementation RADetailMapCell - (void)awakeFromNib { [super awakeFromNib]; // Initialization code self.valueLabel.textContainerInset = UIEdgeInsetsMake(0, -5, 0, -5); } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } - (void)prepareForReuse { [super prepareForReuse]; self.model = nil; } - (void)setModel:(RADetailMapModel *)model { _model = model; self.titleLabel.text = _model.title; self.valueLabel.text = _model.location; if (_model.highlight) { self.valueLabel.textColor = [UIColor redColor]; } else{ self.valueLabel.textColor = [UIColor blackColor]; } NSString *lonStr = _model.lon; NSString *latStr = _model.lat; if (lonStr && lonStr.length > 0 && latStr && latStr.length > 0) { // double longitude = [lonStr doubleValue]; // double latitude = [latStr doubleValue]; // // CLLocationCoordinate2D c2d = CLLocationCoordinate2DMake(latitude, longitude); // // MKCoordinateSpan span = MKCoordinateSpanMake(180, 360); // // 创建一个区域结构体变量 // MKCoordinateRegion region = MKCoordinateRegionMake(c2d, span); // // // 将大头针数据模型添加到MKMapView上管理 // [self.mapView setRegion:region animated:YES]; if ([lonStr isEqualToString:@"-999"] && [latStr isEqualToString:@"-999"]) { self.navigationBtn.enabled = NO; [self.navigationBtn setImage:[UIImage imageNamed:@"btn_map_no"] forState:UIControlStateNormal]; } else { self.navigationBtn.enabled = YES; [self.navigationBtn setImage:[UIImage imageNamed:@"btn_map"] forState:UIControlStateNormal]; } } else { self.navigationBtn.enabled = NO; [self.navigationBtn setImage:[UIImage imageNamed:@"btn_map_no"] forState:UIControlStateNormal]; } if (model.detectTel) { self.valueLabel.dataDetectorTypes = UIDataDetectorTypePhoneNumber; } else { self.valueLabel.dataDetectorTypes = UIDataDetectorTypeNone; } } - (IBAction)navigationBtnClick:(UIButton *)sender { // MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation]; if (self.delegate && [self.delegate respondsToSelector:@selector(mapCell:clickMapButtonWithModel:)]) { [self.delegate mapCell:self clickMapButtonWithModel:self.model]; } } @end