|
|
|
@ -11,13 +11,54 @@
@@ -11,13 +11,54 @@
|
|
|
|
|
#import "ZZBadgeButton.h" |
|
|
|
|
#import "User.h" |
|
|
|
|
#import "ContactsViewController.h" |
|
|
|
|
#import <MapKit/MapKit.h> |
|
|
|
|
#import <AMapFoundationKit/AMapFoundationKit.h> |
|
|
|
|
#import <AMapSearchKit/AMapSearchKit.h> |
|
|
|
|
#import <MAMapKit/MAMapKit.h> |
|
|
|
|
#import "CustomAnnotationView.h" |
|
|
|
|
#import "UserAnnotationView.h" |
|
|
|
|
#import "AppDelegate.h" |
|
|
|
|
|
|
|
|
|
@interface HomeHeaderTableView () |
|
|
|
|
//默认的定位位置 北京 |
|
|
|
|
#define DefineLocate CLLocationCoordinate2DMake(39.9086828351,116.3980865479) |
|
|
|
|
@interface HomeHeaderTableView ()<CLLocationManagerDelegate,MKMapViewDelegate,AMapSearchDelegate> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic ,strong) NSMutableArray *btnArr; |
|
|
|
|
@property (nonatomic ,weak) UILabel *titleLabel; |
|
|
|
|
|
|
|
|
|
@property (nonatomic ,strong) MKMapView *mapView; |
|
|
|
|
|
|
|
|
|
@property (strong, nonatomic) Locate *curLocate;// 设备当前的 位置 |
|
|
|
|
@property (strong, nonatomic) CLLocation *userLocate;// 用户当前的 位置 |
|
|
|
|
@property (strong, nonatomic) MKPointAnnotation *curPointAnnotation; //设备 View |
|
|
|
|
@property (strong, nonatomic) MKPointAnnotation *userPointAnnotation; //用户 View |
|
|
|
|
|
|
|
|
|
//逆地理编码 |
|
|
|
|
@property (nonatomic, strong) AMapReGeocodeSearchRequest *regeo; |
|
|
|
|
//逆地理编码使用的 |
|
|
|
|
@property (nonatomic, strong) AMapSearchAPI *search; |
|
|
|
|
|
|
|
|
|
@property (nonatomic ,strong) UIView *msgView; |
|
|
|
|
|
|
|
|
|
// 定位类型的显示Image |
|
|
|
|
@property (weak, nonatomic) UIImageView *locationTypeImageView; |
|
|
|
|
|
|
|
|
|
// 定位地址内容标题 |
|
|
|
|
@property (weak, nonatomic) UILabel *locationAddressLabel; |
|
|
|
|
|
|
|
|
|
// 定位时间 |
|
|
|
|
@property (weak, nonatomic) UILabel *locationTimeLabel; |
|
|
|
|
|
|
|
|
|
//定位类型 |
|
|
|
|
@property (weak, nonatomic) UILabel *locationTypeLabel; |
|
|
|
|
|
|
|
|
|
//设备电量Image |
|
|
|
|
@property (weak, nonatomic) UIImageView *deviceBatteryImage; |
|
|
|
|
|
|
|
|
|
//设备电量Label |
|
|
|
|
@property (weak, nonatomic) UILabel *deviceBatteryLabel; |
|
|
|
|
|
|
|
|
|
@end |
|
|
|
|
|
|
|
|
|
@implementation HomeHeaderTableView |
|
|
|
@ -36,19 +77,45 @@
@@ -36,19 +77,45 @@
|
|
|
|
|
|
|
|
|
|
- (void)subHeaderView |
|
|
|
|
{ |
|
|
|
|
_tempCarouselView = [[XRCarouselView alloc] initWithFrame:CGRectMake(0, 10, ScreenWidth, ScreenWidth*0.4)]; |
|
|
|
|
_tempCarouselView.changeMode = ChangeModeFade; |
|
|
|
|
_tempCarouselView.time = 5.0f; |
|
|
|
|
_tempCarouselView.imageArray = @[[UIImage imageNamed:@"img_banner"]]; |
|
|
|
|
_tempCarouselView.placeholderImage = [UIImage imageNamed:@"img_banner"]; |
|
|
|
|
[self addSubview:_tempCarouselView]; |
|
|
|
|
// _tempCarouselView = [[XRCarouselView alloc] initWithFrame:CGRectMake(0, 10, ScreenWidth, ScreenWidth*0.4)]; |
|
|
|
|
// _tempCarouselView.changeMode = ChangeModeFade; |
|
|
|
|
// _tempCarouselView.time = 5.0f; |
|
|
|
|
// _tempCarouselView.imageArray = @[[UIImage imageNamed:@"img_banner"]]; |
|
|
|
|
// _tempCarouselView.placeholderImage = [UIImage imageNamed:@"img_banner"]; |
|
|
|
|
// [self addSubview:_tempCarouselView]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIView *topView = [UICommon ui_view:CGRectZero backgroundColor:KKWhiteColorColor cornerRadius:10 borderWidth:0 borderColor:KKWhiteColorColor]; |
|
|
|
|
[self addSubview:topView]; |
|
|
|
|
[topView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
|
|
make.left.right.equalTo(self).inset(15); |
|
|
|
|
make.top.equalTo(self).offset(15); |
|
|
|
|
make.height.mas_equalTo(ScreenWidth*0.6); |
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
[topView addSubview:self.mapView]; |
|
|
|
|
[self.mapView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
|
|
make.left.right.equalTo(topView).inset(8); |
|
|
|
|
make.top.equalTo(topView).offset(8); |
|
|
|
|
make.bottom.equalTo(topView.mas_bottom).inset(8); |
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[topView addSubview:self.msgView]; |
|
|
|
|
[self.msgView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
|
|
make.left.right.equalTo(topView).inset(23); |
|
|
|
|
make.bottom.equalTo(topView.mas_bottom).inset(15); |
|
|
|
|
make.height.mas_equalTo(60); |
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIView *bgView = [UICommon ui_view:CGRectZero backgroundColor:KKWhiteColorColor cornerRadius:10 borderWidth:0 borderColor:KKWhiteColorColor]; |
|
|
|
|
self.bgView = bgView; |
|
|
|
|
[self addSubview:bgView]; |
|
|
|
|
[bgView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
|
|
make.left.right.equalTo(self).inset(15); |
|
|
|
|
make.top.equalTo(_tempCarouselView.mas_bottom).offset(15); |
|
|
|
|
make.top.equalTo(topView.mas_bottom).offset(15); |
|
|
|
|
make.height.mas_equalTo(113); |
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
@ -67,12 +134,12 @@
@@ -67,12 +134,12 @@
|
|
|
|
|
|
|
|
|
|
- (void)subBtnView |
|
|
|
|
{ |
|
|
|
|
[self loadData]; |
|
|
|
|
for (UIButton *views in self.bgView.subviews) |
|
|
|
|
{ |
|
|
|
|
[views removeFromSuperview]; |
|
|
|
|
} |
|
|
|
|
self.btnArr = [NSMutableArray new]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSMutableArray *titleArray = [NSMutableArray new]; |
|
|
|
@ -192,6 +259,359 @@
@@ -192,6 +259,359 @@
|
|
|
|
|
return customButton; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
-(MKMapView *)mapView |
|
|
|
|
{ |
|
|
|
|
if (!_mapView) |
|
|
|
|
{ |
|
|
|
|
_mapView = [MKMapView new]; |
|
|
|
|
_mapView.delegate=self; |
|
|
|
|
UITapGestureRecognizer *tapPress = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(mapViewtapPressed)]; |
|
|
|
|
[_mapView addGestureRecognizer:tapPress]; |
|
|
|
|
} |
|
|
|
|
return _mapView; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)loadData |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
// [self.locationManager startUpdatingLocation]; |
|
|
|
|
if(cUser.cDevice.lastLocation){ |
|
|
|
|
|
|
|
|
|
self.curLocate = cUser.cDevice.lastLocation; |
|
|
|
|
[self showCurPiont]; |
|
|
|
|
[self mapView:self.mapView didSelectAnnotationView:[CustomAnnotationView new]]; |
|
|
|
|
self.deviceBatteryImage.hidden = NO; |
|
|
|
|
self.deviceBatteryLabel.hidden = NO; |
|
|
|
|
self.locationTypeImageView.hidden = NO; |
|
|
|
|
[self.locationAddressLabel mas_remakeConstraints:^(MASConstraintMaker *make) { |
|
|
|
|
make.left.equalTo(self.locationTypeImageView.mas_right).offset(15); |
|
|
|
|
make.right.equalTo(self.msgView.mas_right).inset(15); |
|
|
|
|
make.top.equalTo(self.locationTimeLabel.mas_bottom).offset(5); |
|
|
|
|
}]; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
[self setMapZoom:DefineLocate]; |
|
|
|
|
self.locationTimeLabel.text = @""; |
|
|
|
|
self.locationTypeLabel.text = @""; |
|
|
|
|
self.locationAddressLabel.text = @"当前位置未知,请确保设备开机且能够联网,再点击定位按钮进行定位"; |
|
|
|
|
self.deviceBatteryImage.hidden = YES; |
|
|
|
|
self.deviceBatteryLabel.hidden = YES; |
|
|
|
|
self.locationTypeImageView.hidden = YES; |
|
|
|
|
[self.locationAddressLabel mas_remakeConstraints:^(MASConstraintMaker *make) { |
|
|
|
|
make.right.left.equalTo(self.msgView).inset(15); |
|
|
|
|
make.centerY.equalTo(self.msgView); |
|
|
|
|
}]; |
|
|
|
|
} |
|
|
|
|
[self setBattery:cUser.cDevice.battery.intValue]; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)setBattery:(int)battery |
|
|
|
|
{ |
|
|
|
|
// 电量 |
|
|
|
|
NSString *imageName = @""; |
|
|
|
|
if(battery == 0) |
|
|
|
|
imageName = @"battery_0"; |
|
|
|
|
else if (battery < 10) |
|
|
|
|
imageName = @"battery_low"; |
|
|
|
|
else if (battery < 20) |
|
|
|
|
imageName = @"battery_1"; |
|
|
|
|
else if (battery < 30) |
|
|
|
|
imageName = @"battery_2"; |
|
|
|
|
else if (battery < 40) |
|
|
|
|
imageName = @"battery_3"; |
|
|
|
|
else if (battery < 50) |
|
|
|
|
imageName = @"battery_4"; |
|
|
|
|
else if (battery < 60) |
|
|
|
|
imageName = @"battery_4"; |
|
|
|
|
else if (battery < 70) |
|
|
|
|
imageName = @"battery_6"; |
|
|
|
|
else if (battery < 80) |
|
|
|
|
imageName = @"battery_7"; |
|
|
|
|
else if (battery < 90) |
|
|
|
|
imageName = @"battery_8"; |
|
|
|
|
else if (battery < 100) |
|
|
|
|
imageName = @"battery_9"; |
|
|
|
|
else |
|
|
|
|
imageName = @"battery_10"; |
|
|
|
|
self.deviceBatteryImage.image = [myHelper getImageWithName:imageName]; |
|
|
|
|
self.deviceBatteryLabel.text = [NSString stringWithFormat:@"%d%%",battery]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//MARK: 显示点 |
|
|
|
|
/** |
|
|
|
|
显示点 |
|
|
|
|
*/ |
|
|
|
|
-(void)showCurPiont |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
//要在地图上显示的点的数组 |
|
|
|
|
NSMutableArray *pointArr = [NSMutableArray array]; |
|
|
|
|
|
|
|
|
|
CLLocationCoordinate2D coordinate2D = DefineLocate; |
|
|
|
|
if (self.curLocate) { |
|
|
|
|
//设置新的地图信息 |
|
|
|
|
coordinate2D = CLLocationCoordinate2DMake([self.curLocate.lat doubleValue], |
|
|
|
|
[self.curLocate.lon doubleValue]); |
|
|
|
|
//删除原来的点 |
|
|
|
|
if ([self.mapView.annotations containsObject:self.curPointAnnotation]) { |
|
|
|
|
// NSInteger index = [self.mapView.annotations indexOfObject:curPointAnnotation]; |
|
|
|
|
[self.mapView removeAnnotation:self.curPointAnnotation]; |
|
|
|
|
} |
|
|
|
|
self.curPointAnnotation.coordinate = coordinate2D; |
|
|
|
|
|
|
|
|
|
// 设备的 范围框 |
|
|
|
|
if (self.curLocate.radius) { |
|
|
|
|
CLLocationDistance radius = [self.curLocate.radius doubleValue]; |
|
|
|
|
MKCircle *circle = [MKCircle circleWithCenterCoordinate:coordinate2D |
|
|
|
|
radius:radius]; |
|
|
|
|
[self.mapView removeOverlays:self.mapView.overlays]; |
|
|
|
|
[self.mapView addOverlay:circle]; |
|
|
|
|
} |
|
|
|
|
[pointArr addObject:self.curPointAnnotation]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(pointArr.count > 0){ |
|
|
|
|
//如果 设备的位置存在则显示 设备的位置 |
|
|
|
|
[self.mapView addAnnotations:pointArr]; |
|
|
|
|
[self setMapZoom:coordinate2D]; |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
//调整位置 |
|
|
|
|
//设置中心点为当前地图范围的中心点 |
|
|
|
|
CLLocationCoordinate2D center = DefineLocate; |
|
|
|
|
//不存在 则 显示用户的位置 |
|
|
|
|
if(self.mapView.userLocation.isUpdating){ |
|
|
|
|
center = self.mapView.userLocation.coordinate; |
|
|
|
|
}else if(self.userLocate){ |
|
|
|
|
center = self.userLocate.coordinate; |
|
|
|
|
} |
|
|
|
|
[self setMapZoom:center]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#pragma 缩小地图 |
|
|
|
|
- (void)setMapZoom:(CLLocationCoordinate2D)centerCoordinate{ |
|
|
|
|
// if (self.mapView.region.span.latitudeDelta > 20) { |
|
|
|
|
|
|
|
|
|
// MARK: carh update by lsz 22-5-12 增加坐标合法性判断 |
|
|
|
|
@try { |
|
|
|
|
if (CLLocationCoordinate2DIsValid(centerCoordinate)) { |
|
|
|
|
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(centerCoordinate, 2000, 2000); |
|
|
|
|
[self.mapView setRegion:region animated:YES]; |
|
|
|
|
} |
|
|
|
|
} @catch (NSException *exception) { |
|
|
|
|
|
|
|
|
|
} @finally { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#pragma mark - 地图控件代理方法 |
|
|
|
|
#pragma mark 显示大头针时调用,注意方法中的annotation参数是即将显示的大头针对象 |
|
|
|
|
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{ |
|
|
|
|
|
|
|
|
|
if([annotation isEqual:self.curPointAnnotation]){ |
|
|
|
|
//由于当前位置的标注也是一个大头针,所以此时需要判断,此代理方法返回nil使用默认大头针视图 |
|
|
|
|
static NSString *key1=@"CustomAnnotationView"; |
|
|
|
|
CustomAnnotationView *annotationView = (CustomAnnotationView*)[_mapView dequeueReusableAnnotationViewWithIdentifier:key1]; |
|
|
|
|
//如果缓存池中不存在则新建 |
|
|
|
|
if (!annotationView) { |
|
|
|
|
annotationView =[[CustomAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:key1]; |
|
|
|
|
annotationView.canShowCallout=NO;//不允许交互点击 |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
//重新设置此类大头针视图的大头针模型(因为有可能是从缓存池中取出来的,位置是放到缓存池时的位置) |
|
|
|
|
annotationView.annotation = annotation; |
|
|
|
|
} |
|
|
|
|
//修改大头针视图 设置成头像 |
|
|
|
|
[annotationView setImageWithURLString:cUser.cDevice.avator]; |
|
|
|
|
//设置大小 |
|
|
|
|
annotationView.frame = CGRectMake(0, 0, 40.5, 60); |
|
|
|
|
//设置中心偏移量 |
|
|
|
|
annotationView.centerOffset = CGPointMake(0, -26); |
|
|
|
|
//定义详情视图偏移量 |
|
|
|
|
annotationView.calloutOffset=CGPointMake(0, 12); |
|
|
|
|
return annotationView; |
|
|
|
|
}else if([annotation isKindOfClass:[MKUserLocation class]]){ |
|
|
|
|
//由于当前位置的标注也是一个大头针,所以此时需要判断,此代理方法返回nil使用默认大头针视图 |
|
|
|
|
static NSString *key1=@"UserAnnotationView"; |
|
|
|
|
UserAnnotationView *annotationView = (UserAnnotationView*)[_mapView dequeueReusableAnnotationViewWithIdentifier:key1]; |
|
|
|
|
//如果缓存池中不存在则新建 |
|
|
|
|
if (!annotationView) { |
|
|
|
|
annotationView =[[UserAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:key1]; |
|
|
|
|
annotationView.canShowCallout=NO;//不允许交互点击 |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
//重新设置此类大头针视图的大头针模型(因为有可能是从缓存池中取出来的,位置是放到缓存池时的位置) |
|
|
|
|
annotationView.annotation = annotation; |
|
|
|
|
} |
|
|
|
|
//修改大头针视图 设置成头像 |
|
|
|
|
[annotationView setImageWithURLString:cUser.avator]; |
|
|
|
|
//设置大小 |
|
|
|
|
annotationView.frame = CGRectMake(0, 0, 40.5, 60); |
|
|
|
|
//设置中心偏移量 |
|
|
|
|
annotationView.centerOffset = CGPointMake(0, -26); |
|
|
|
|
//定义详情视图偏移量 |
|
|
|
|
annotationView.calloutOffset=CGPointMake(0, 12); |
|
|
|
|
return annotationView; |
|
|
|
|
} |
|
|
|
|
return nil; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//MARK: 点击地图 中的 标点 触发的方法 |
|
|
|
|
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view |
|
|
|
|
{ |
|
|
|
|
if([view isKindOfClass:[CustomAnnotationView class]]) |
|
|
|
|
{ |
|
|
|
|
// 设备点 |
|
|
|
|
self.locationTypeLabel.text = self.curLocate.loc_type; |
|
|
|
|
if ([self.curLocate.loc_type isEqualToString:@"LBS"]) { |
|
|
|
|
self.locationTypeImageView.image = [UIImage imageNamed:@"icon_base_station"]; |
|
|
|
|
}else if([self.curLocate.loc_type isEqualToString:@"GPS"]){ |
|
|
|
|
self.locationTypeImageView.image = [UIImage imageNamed:@"icon_positioning_g"]; |
|
|
|
|
}else if([self.curLocate.loc_type isEqualToString:@"WIFI"]){ |
|
|
|
|
self.locationTypeImageView.image = [UIImage imageNamed:@"icon_home_wifi"]; |
|
|
|
|
}else{ |
|
|
|
|
//是空的 LBS |
|
|
|
|
self.locationTypeImageView.image = [UIImage imageNamed:@"icon_base_station"]; |
|
|
|
|
self.locationTypeLabel.text = @"LBS"; |
|
|
|
|
} |
|
|
|
|
if(self.curLocate){ |
|
|
|
|
NSString *dateStr = [myHelper distanceTimeWithBeforeTime:[self.curLocate.timestamp doubleValue]]; |
|
|
|
|
self.locationTimeLabel.text = dateStr; |
|
|
|
|
self.locationAddressLabel.text = self.curLocate.address.length > 0 ? self.curLocate.address : @"位置解析中..."; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
self.regeo.location = [AMapGeoPoint locationWithLatitude:[self.curLocate.lat floatValue] longitude:[self.curLocate.lon floatValue]]; |
|
|
|
|
[self.search AMapReGoecodeSearch:self.regeo]; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
- (AMapReGeocodeSearchRequest *)regeo { |
|
|
|
|
if (!_regeo) { |
|
|
|
|
_regeo = [[AMapReGeocodeSearchRequest alloc]init]; |
|
|
|
|
_regeo.requireExtension = YES; |
|
|
|
|
} |
|
|
|
|
return _regeo; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (AMapSearchAPI *)search { |
|
|
|
|
if (!_search) { |
|
|
|
|
_search = [[AMapSearchAPI alloc]init]; |
|
|
|
|
_search.delegate = self; |
|
|
|
|
} |
|
|
|
|
return _search; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (MKOverlayRenderer *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay |
|
|
|
|
{ |
|
|
|
|
if ([overlay isKindOfClass:[MKCircle class]]) |
|
|
|
|
{ |
|
|
|
|
MKCircleRenderer *circle = [[MKCircleRenderer alloc] initWithOverlay:overlay]; |
|
|
|
|
circle.strokeColor = [UIColor clearColor]; |
|
|
|
|
|
|
|
|
|
circle.fillColor = [[UIColor blueColor] colorWithAlphaComponent:0.1]; |
|
|
|
|
|
|
|
|
|
// circle.lineWidth = 1; |
|
|
|
|
return circle; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return nil; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#pragma mark ====高德地图位置解析回调==== |
|
|
|
|
|
|
|
|
|
-(void)onReGeocodeSearchDone:(AMapReGeocodeSearchRequest *)request response:(AMapReGeocodeSearchResponse *)response{ |
|
|
|
|
if (response.regeocode != nil) |
|
|
|
|
{ |
|
|
|
|
NSString *name = response.regeocode.formattedAddress; |
|
|
|
|
self.locationAddressLabel.text = name; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (UIView *)msgView |
|
|
|
|
{ |
|
|
|
|
if (!_msgView) |
|
|
|
|
{ |
|
|
|
|
self.curPointAnnotation = [[MKPointAnnotation alloc] init]; |
|
|
|
|
self.userPointAnnotation = [[MKPointAnnotation alloc] init]; |
|
|
|
|
|
|
|
|
|
_msgView = [UICommon ui_view:CGRectZero backgroundColor:KKWhiteColorColor cornerRadius:10 borderWidth:0 borderColor:KKClearColor]; |
|
|
|
|
|
|
|
|
|
UIImageView *locationTypeImageView = [UIImageView new]; |
|
|
|
|
self.locationTypeImageView = locationTypeImageView; |
|
|
|
|
[_msgView addSubview:locationTypeImageView]; |
|
|
|
|
[locationTypeImageView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
|
|
make.left.equalTo(_msgView).offset(15); |
|
|
|
|
make.top.equalTo(_msgView).offset(14); |
|
|
|
|
make.size.mas_equalTo(CGSizeMake(20, 18)); |
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
//定位类型 |
|
|
|
|
UILabel *locationTypeLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:Font_(12) textColor:KKTextColor text:@"" Radius:0]; |
|
|
|
|
self.locationTypeLabel = locationTypeLabel; |
|
|
|
|
[_msgView addSubview:locationTypeLabel]; |
|
|
|
|
[locationTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
|
|
make.centerX.equalTo(locationTypeImageView); |
|
|
|
|
make.top.equalTo(locationTypeImageView.mas_bottom).offset(2); |
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
/// 时间 |
|
|
|
|
UILabel *locationTimeLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:Font_(12) textColor:KKTextColor text:@"" Radius:0]; |
|
|
|
|
self.locationTimeLabel = locationTimeLabel; |
|
|
|
|
[_msgView addSubview:locationTimeLabel]; |
|
|
|
|
[locationTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
|
|
make.left.equalTo(locationTypeImageView.mas_right).offset(15); |
|
|
|
|
make.top.equalTo(_msgView).offset(7); |
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
//电量 |
|
|
|
|
UILabel *deviceBatteryLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:Font_(12) textColor:KKTextColor text:@"" Radius:0]; |
|
|
|
|
self.deviceBatteryLabel = deviceBatteryLabel; |
|
|
|
|
[_msgView addSubview:deviceBatteryLabel]; |
|
|
|
|
[deviceBatteryLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
|
|
make.right.equalTo(_msgView.mas_right).inset(15); |
|
|
|
|
make.centerY.equalTo(locationTimeLabel); |
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
/// 设备电量图片 |
|
|
|
|
UIImageView *deviceBatteryImage = [UICommon ui_imageView:CGRectZero fileName:@""]; |
|
|
|
|
self.deviceBatteryImage = deviceBatteryImage; |
|
|
|
|
[_msgView addSubview:deviceBatteryImage]; |
|
|
|
|
[deviceBatteryImage mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
|
|
make.right.equalTo(deviceBatteryLabel.mas_left).inset(5); |
|
|
|
|
make.centerY.equalTo(deviceBatteryLabel); |
|
|
|
|
make.size.mas_equalTo(CGSizeMake(23, 8)); |
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UILabel *locationAddressLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentLeft font:Font_(12) textColor:KKTextColor text:@"当前位置未知,请确保设备开机且能够联网,再点击定位按钮进行定位" Radius:0]; |
|
|
|
|
self.locationAddressLabel = locationAddressLabel; |
|
|
|
|
[_msgView addSubview:locationAddressLabel]; |
|
|
|
|
[locationAddressLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
|
|
make.left.equalTo(locationTypeImageView.mas_right).offset(15); |
|
|
|
|
make.right.equalTo(_msgView.mas_right).inset(15); |
|
|
|
|
make.top.equalTo(locationTimeLabel.mas_bottom).offset(5); |
|
|
|
|
}]; |
|
|
|
|
UITapGestureRecognizer *tapPress = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(mapViewtapPressed)]; |
|
|
|
|
[_msgView addGestureRecognizer:tapPress]; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return _msgView; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)mapViewtapPressed |
|
|
|
|
{ |
|
|
|
|
AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate; |
|
|
|
|
[UICommon currentVC].tabBarController.selectedIndex = 2; |
|
|
|
|
app.tabbarView.mytabbar.buttonSelectON = YES; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
// Only override drawRect: if you perform custom drawing. |
|
|
|
|
// An empty implementation adversely affects performance during animation. |
|
|
|
@ -201,3 +621,4 @@
@@ -201,3 +621,4 @@
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
@end |
|
|
|
|
|
|
|
|
|