| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- //
- // RADetailMapCell.m
- // Apex And Drivers
- //
- // Created by Jack on 2018/9/4.
- // Copyright © 2018年 USAI. All rights reserved.
- //
- #import "RADetailMapCell.h"
- #import <MapKit/MapKit.h>
- #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];
- }
- }
- - (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
|