Merge branch 'develop'

# Conflicts:
#	.DS_Store
This commit is contained in:
一只会编程的狮子
2019-05-15 20:26:51 +08:00
617 changed files with 25959 additions and 9374 deletions
Binary file not shown.
@@ -169,7 +169,7 @@ typedef NS_ENUM(NSInteger, IfishDoctorPayType){
-(void)creatTab{
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height) style:UITableViewStylePlain];
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height-TOP_HEIGHT) style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.scrollEnabled = YES;
@@ -26,7 +26,7 @@
-(void)creatTab{
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height) style:UITableViewStyleGrouped];
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height-TOP_HEIGHT) style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.scrollEnabled = YES;
@@ -37,7 +37,7 @@
[self.view addSubview:self.tableView];
UIButton *duiHuanBtn=[UIButton buttonWithType:UIButtonTypeCustom];
duiHuanBtn.frame = CGRectMake(0, self.view.frame.size.height -49, self.view.frame.size.width, 49);
duiHuanBtn.frame = CGRectMake(0, 0, self.view.frame.size.width, 49);
[duiHuanBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
NSMutableAttributedString *title = [[NSMutableAttributedString alloc] initWithString:@"立即兑换"];
@@ -47,9 +47,7 @@
[duiHuanBtn setAttributedTitle:title forState:UIControlStateNormal];
[duiHuanBtn setBackgroundColor:RGB(67, 186, 255)];
[duiHuanBtn addTarget:self action:@selector(duihuanBtnClick) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:duiHuanBtn];
self.tableView.tableFooterView = duiHuanBtn;
}
@@ -87,17 +85,6 @@
return 470;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 10;
}
#pragma mark -金币兑换
-(void)duihuanBtnClick{
@@ -15,6 +15,7 @@
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSMutableArray *dataArr;
@property (nonatomic) NSIndexPath *selectIndexPath;
@property(nonatomic,strong) UIView *sectionHeaderView;
@property (nonatomic) BOOL isChage;
@end
@@ -57,7 +58,7 @@
-(void)creatTab{
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height) style:UITableViewStyleGrouped];
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height-TOP_HEIGHT) style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.scrollEnabled = YES;
@@ -99,13 +100,26 @@
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.1;
return CGFLOAT_MIN;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
return nil;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 0.1;
return 10;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
return self.sectionHeaderView;
}
-(UIView *)sectionHeaderView {
if (!_sectionHeaderView) {
_sectionHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
}
return _sectionHeaderView;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
@@ -159,7 +159,7 @@ BOOL cerViewFormRootVC;
-(void)creatTab{
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0, kScreenSize.width,kScreenSize.height - 49 ) style:UITableViewStylePlain];
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0, kScreenSize.width,kScreenSize.height - 49 -TOP_HEIGHT ) style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.scrollEnabled = YES;
@@ -20,7 +20,6 @@
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self addTitleViewWithTitle:@"分享中"];
//自定义封装播放器 由于xib创建OPGLview 无法显示(暂未找到方法)暂时不用 纯代码建UI可以试试
//[self setupVideoPlayView];
@@ -32,9 +31,14 @@
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.navigationBar.translucent = YES;
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
self.navigationController.navigationBar.translucent = NO;
}
-(void)resetBootomView{
@@ -80,9 +80,8 @@
pageController.selectIndex = 0;
//pageController.menuViewBottomSpace = 10;
[self addChildViewController: pageController];
CGFloat height = [UIApplication sharedApplication].statusBarFrame.size.height + 44;
//看看在tab中时
pageController.viewFrame = CGRectMake(0,height,self.view.frame.size.width, self.view.frame.size.height - height) ;
pageController.viewFrame = CGRectMake(0,0,self.view.frame.size.width, self.view.frame.size.height-49) ;
self.pageController = pageController;
[self.view addSubview: pageController.view];
@@ -175,7 +175,7 @@
}
-(void)creatTab{
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height ) style:UITableViewStylePlain];
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height-TOP_HEIGHT) style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self;
@@ -9,9 +9,9 @@
#import "IfishShopEditeNewViewController.h"
#import "ChinaPlckerView.h"
#import "UITextField+KeyBordDoneView.h"
#import <BaiduMapAPI_Location/BMKLocationService.h>
#import <BaiduMapAPI_Search/BMKSearchComponent.h>
#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>
//#import <BaiduMapAPI_Location/BMKLocationService.h>
//#import <BaiduMapAPI_Search/BMKSearchComponent.h>
//#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>
#import "UIImageView+WebCache.h"
#import "IfishShopEdite1Cell.h"
#import "IfishShopEdite2ViewCell.h"
@@ -32,6 +32,7 @@
static const CGFloat rectWidth = 300;
static const CGFloat rectHeight = 168;
#import "CusomeCameraViewController.h"
#import <CoreLocation/CoreLocation.h>
@interface IfishShopEditeNewViewController ()<UITableViewDelegate,
UITableViewDataSource,
@@ -40,19 +41,21 @@ UIImagePickerControllerDelegate,
UIActionSheetDelegate,
UINavigationControllerDelegate,
ChinaPlckerViewDelegate,
BMKLocationServiceDelegate,
BMKGeoCodeSearchDelegate,
CLLocationManagerDelegate,
//BMKGeoCodeSearchDelegate,
UIGestureRecognizerDelegate>
{
BMKGeoCodeSearch*_geocodesearch;
// BMKGeoCodeSearch*_geocodesearch;
BOOL _isUpdate;
}
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong) NSArray *titles;
@property(nonatomic,strong) NSString *address;
@property(nonatomic)BMKLocationService*locService;
//@property(nonatomic)BMKLocationService*locService;
@property (nonatomic,strong ) CLLocationManager *locationManager;//定位服务
@property (nonatomic,copy) NSString *currentCity;//城市
@property(nonatomic,strong) NSString *privence;
@property(nonatomic,strong) NSString *city;
@property(nonatomic,strong) NSString *area;
@@ -88,84 +91,151 @@ UIGestureRecognizerDelegate>
#pragma mark 定位
-(void)getLocation{
//初始化BMKLocationService
_locService=[[BMKLocationService alloc]init];
_locService.delegate=self;
//启动LocationService
[_locService startUserLocationService];
_geocodesearch=[[BMKGeoCodeSearch alloc]init];
// _locService=[[BMKLocationService alloc]init];
// _locService.delegate=self;
// //启动LocationService
// [_locService startUserLocationService];
// _geocodesearch=[[BMKGeoCodeSearch alloc]init];
if ([CLLocationManager locationServicesEnabled]) {
_locationManager = [[CLLocationManager alloc]init];
_locationManager.delegate = self;
[_locationManager requestAlwaysAuthorization];
_currentCity = [[NSString alloc]init];
[_locationManager requestWhenInUseAuthorization];
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
_locationManager.distanceFilter = 5.0;
[_locationManager startUpdatingLocation];
}
}
//处理方向变更信息
- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
{
//NSLog(@"heading is %@",userLocation.heading);
}
//处理位置坐标更新
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
{
//NSLog(@"didUpdateUserLocation lat %f,long %f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
[self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
// static dispatch_once_t disOnce;
// dispatch_once(&disOnce, ^ {
//
// [self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
// });
#pragma mark - 定位失败
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"请在设置中打开定位" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"打开定位" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSURL *settingURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication]openURL:settingURL];
}];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
[alert addAction:cancel];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
#pragma mark - 定位成功
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
[_locationManager stopUpdatingLocation];
CLLocation *currentLocation = [locations lastObject];
CLGeocoder *geoCoder = [[CLGeocoder alloc]init];
//当前的经纬度
NSLog(@"当前的经纬度 %f,%f",currentLocation.coordinate.latitude,currentLocation.coordinate.longitude);
//这里的代码是为了判断didUpdateLocations调用了几次 有可能会出现多次调用 为了避免不必要的麻烦 在这里加个if判断 如果大于1.0就return
NSTimeInterval locationAge = -[currentLocation.timestamp timeIntervalSinceNow];
if (locationAge > 1.0){//如果调用已经一次,不再执行
return;
}
//地理反编码 可以根据坐标(经纬度)确定位置信息(街道 门牌等)
[geoCoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {
if (placemarks.count >0) {
CLPlacemark *placeMark = placemarks[0];
_currentCity = placeMark.locality;
if (!_currentCity) {
_currentCity = @"无法定位当前城市";
}
//看需求定义一个全局变量来接收赋值
NSLog(@"当前国家 - %@",placeMark.country);//当前国家
NSLog(@"当前城市 - %@",_currentCity);//当前城市
NSLog(@"当前位置 - %@",placeMark.subLocality);//当前位置
NSLog(@"当前街道 - %@",placeMark.thoroughfare);//当前街道
NSLog(@"具体地址 - %@",placeMark.name);//具体地址
NSString *message = [NSString stringWithFormat:@"%@,%@,%@,%@,%@",placeMark.country,_currentCity,placeMark.subLocality,placeMark.thoroughfare,placeMark.name];
self.address=message;
}else if (error == nil && placemarks.count){
NSLog(@"NO location and error return");
}else if (error){
NSLog(@"loction error:%@",error);
}
}];
}
//处理方向变更信息
//- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
//{
// //NSLog(@"heading is %@",userLocation.heading);
//}
//处理位置坐标更新
//- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
//{
// //NSLog(@"didUpdateUserLocation lat %f,long %f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
// [self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
// // static dispatch_once_t disOnce;
// // dispatch_once(&disOnce, ^ {
// //
// // [self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
// // });
//
//}
/**
* 地理反编码
*/
-(void)reverseGeoCodeWithlatitude:(CLLocationDegrees)latitude addlongitude:(CLLocationDegrees)longitude{
CLLocationCoordinate2D pt=(CLLocationCoordinate2D){latitude,longitude};
BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
reverseGeocodeSearchOption.reverseGeoPoint=pt;
BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
if(flag)
{
NSLog(@"反geo检索发送成功");
}
else
{
NSLog(@"反geo检索发送失败");
}
}
-(void)dealloc{
if (_geocodesearch!=nil) {
_geocodesearch=nil;
}
}
//-(void)reverseGeoCodeWithlatitude:(CLLocationDegrees)latitude addlongitude:(CLLocationDegrees)longitude{
// CLLocationCoordinate2D pt=(CLLocationCoordinate2D){latitude,longitude};
// BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
// reverseGeocodeSearchOption.reverseGeoPoint=pt;
// BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
// if(flag)
// {
// NSLog(@"反geo检索发送成功");
// }
// else
// {
// NSLog(@"反geo检索发送失败");
// }
//
//}
//-(void)dealloc{
//
// if (_geocodesearch!=nil) {
// _geocodesearch=nil;
// }
//}
#pragma mark BMKGeoCodeSearchDelegate
-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
NSLog(@"address%@",result.address);
self.address = result.address;
// IfishSHopEdite3ViewCell *cell = [self.view viewWithTag:CELL6_TAG];
// if (cell) {
// cell.addressFiled.text= self.address;
// }
// static dispatch_once_t disOnce;
// dispatch_once(&disOnce, ^ {
// [self.tableView reloadData];
// });
}
//-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
// NSLog(@"address%@",result.address);
// self.address = result.address;
//
//
// // IfishSHopEdite3ViewCell *cell = [self.view viewWithTag:CELL6_TAG];
//
// // if (cell) {
//
// // cell.addressFiled.text= self.address;
//
// // }
//
// // static dispatch_once_t disOnce;
// // dispatch_once(&disOnce, ^ {
//
// // [self.tableView reloadData];
//
// // });
//
//
//}
- (void)onGetGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
}
//- (void)onGetGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
//
//
//}
-(void)goBackAction{
@@ -196,8 +266,8 @@ UIGestureRecognizerDelegate>
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
_geocodesearch.delegate=self;// 此处记得不用的时候需要置nil,
_locService.delegate=self;
// _geocodesearch.delegate=self;// 此处记得不用的时候需要置nil,
// _locService.delegate=self;
}
@@ -213,7 +283,7 @@ UIGestureRecognizerDelegate>
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
_locService.delegate=nil;
// _locService.delegate=nil;
// 开启
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
@@ -15,22 +15,24 @@
#define CELLPCA_TAG 11111001
#define CELLTAGS_INFO 10000
#import "ChinaPlckerView.h"
#import <BaiduMapAPI_Location/BMKLocationService.h>
#import <BaiduMapAPI_Search/BMKSearchComponent.h>
#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>
//#import <BaiduMapAPI_Location/BMKLocationService.h>
//#import <BaiduMapAPI_Search/BMKSearchComponent.h>
//#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>
#import "FishShopCer.h"
@interface ShopCerPart1InfoViewCell ()<UITableViewDelegate,UITableViewDataSource,UITextViewDelegate,UITextFieldDelegate, ChinaPlckerViewDelegate,BMKLocationServiceDelegate,
BMKGeoCodeSearchDelegate>
#import <CoreLocation/CoreLocation.h>
@interface ShopCerPart1InfoViewCell ()<UITableViewDelegate,UITableViewDataSource,UITextViewDelegate,UITextFieldDelegate, ChinaPlckerViewDelegate,CLLocationManagerDelegate>
{
BMKGeoCodeSearch*_geocodesearch;
//BMKGeoCodeSearch*_geocodesearch;
}
@property(nonatomic,strong) NSString *privence;
@property(nonatomic,strong) NSString *city;
@property(nonatomic,strong) NSString *area;
@property(nonatomic,strong) NSString *address;
@property(nonatomic)BMKLocationService *locService;
//@property(nonatomic)BMKLocationService *locService;
@property (nonatomic,strong ) CLLocationManager *locationManager;//定位服务
@property (nonatomic,copy) NSString *currentCity;//城市
@end
@@ -52,79 +54,152 @@ BMKGeoCodeSearchDelegate>
#pragma mark 定位
-(void)getLocation{
//初始化BMKLocationService
_locService=[[BMKLocationService alloc]init];
_locService.delegate=self;
//启动LocationService
[_locService startUserLocationService];
_geocodesearch=[[BMKGeoCodeSearch alloc]init];
_geocodesearch.delegate=self;// 此处记得不用的时候需要置nil,
// _locService=[[BMKLocationService alloc]init];
// _locService.delegate=self;
// //启动LocationService
// [_locService startUserLocationService];
// _geocodesearch=[[BMKGeoCodeSearch alloc]init];
// _geocodesearch.delegate=self;// 此处记得不用的时候需要置nil,
if ([CLLocationManager locationServicesEnabled]) {
_locationManager = [[CLLocationManager alloc]init];
_locationManager.delegate = self;
[_locationManager requestAlwaysAuthorization];
_currentCity = [[NSString alloc]init];
[_locationManager requestWhenInUseAuthorization];
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
_locationManager.distanceFilter = 5.0;
[_locationManager startUpdatingLocation];
}
}
#pragma mark - 定位失败
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"请在设置中打开定位" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"打开定位" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSURL *settingURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication]openURL:settingURL];
}];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
[alert addAction:cancel];
[alert addAction:ok];
[self.window.rootViewController presentViewController:alert animated:YES completion:nil];
}
#pragma mark - 定位成功
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
[_locationManager stopUpdatingLocation];
CLLocation *currentLocation = [locations lastObject];
CLGeocoder *geoCoder = [[CLGeocoder alloc]init];
//当前的经纬度
NSLog(@"当前的经纬度 %f,%f",currentLocation.coordinate.latitude,currentLocation.coordinate.longitude);
//这里的代码是为了判断didUpdateLocations调用了几次 有可能会出现多次调用 为了避免不必要的麻烦 在这里加个if判断 如果大于1.0就return
NSTimeInterval locationAge = -[currentLocation.timestamp timeIntervalSinceNow];
if (locationAge > 1.0){//如果调用已经一次,不再执行
return;
}
//地理反编码 可以根据坐标(经纬度)确定位置信息(街道 门牌等)
[geoCoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {
if (placemarks.count >0) {
CLPlacemark *placeMark = placemarks[0];
_currentCity = placeMark.locality;
if (!_currentCity) {
_currentCity = @"无法定位当前城市";
}
//看需求定义一个全局变量来接收赋值
NSLog(@"当前国家 - %@",placeMark.country);//当前国家
NSLog(@"当前城市 - %@",_currentCity);//当前城市
NSLog(@"当前位置 - %@",placeMark.subLocality);//当前位置
NSLog(@"当前街道 - %@",placeMark.thoroughfare);//当前街道
NSLog(@"具体地址 - %@",placeMark.name);//具体地址
NSString *message = [NSString stringWithFormat:@"%@,%@,%@,%@,%@",placeMark.country,_currentCity,placeMark.subLocality,placeMark.thoroughfare,placeMark.name];
self.address = message;
NSIndexPath *index=[NSIndexPath indexPathForRow:4 inSection:0];
NSArray *dexArr = @[index];
[self.firstPartTab reloadRowsAtIndexPaths:dexArr withRowAnimation:UITableViewRowAnimationNone];
}else if (error == nil && placemarks.count){
NSLog(@"NO location and error return");
}else if (error){
NSLog(@"loction error:%@",error);
}
}];
}
//处理方向变更信息
- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
{
//NSLog(@"heading is %@",userLocation.heading);
}
//- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
//{
// //NSLog(@"heading is %@",userLocation.heading);
//}
//处理位置坐标更新
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
{
//NSLog(@"didUpdateUserLocation lat %f,long %f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
[self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
// static dispatch_once_t disOnce;
// dispatch_once(&disOnce, ^ {
//
// [self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
// });
}
//- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
//{
// //NSLog(@"didUpdateUserLocation lat %f,long %f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
// [self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
// // static dispatch_once_t disOnce;
// // dispatch_once(&disOnce, ^ {
// //
// // [self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
// // });
//
//}
/**
* 地理反编码
*/
-(void)reverseGeoCodeWithlatitude:(CLLocationDegrees)latitude addlongitude:(CLLocationDegrees)longitude{
CLLocationCoordinate2D pt=(CLLocationCoordinate2D){latitude,longitude};
BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
reverseGeocodeSearchOption.reverseGeoPoint=pt;
BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
if(flag)
{
NSLog(@"反geo检索发送成功");
}
else
{
NSLog(@"反geo检索发送失败");
}
}
-(void)dealloc{
if (_geocodesearch!=nil) {
_geocodesearch=nil;
}
}
//-(void)reverseGeoCodeWithlatitude:(CLLocationDegrees)latitude addlongitude:(CLLocationDegrees)longitude{
// CLLocationCoordinate2D pt=(CLLocationCoordinate2D){latitude,longitude};
// BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
// reverseGeocodeSearchOption.reverseGeoPoint=pt;
// BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
// if(flag)
// {
// NSLog(@"反geo检索发送成功");
// }
// else
// {
// NSLog(@"反geo检索发送失败");
// }
//
//}
//-(void)dealloc{
//
// if (_geocodesearch!=nil) {
// _geocodesearch=nil;
// }
//}
#pragma mark BMKGeoCodeSearchDelegate
-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
NSLog(@"address%@",result.address);
self.address = result.address;
NSIndexPath *index=[NSIndexPath indexPathForRow:4 inSection:0];
NSArray *dexArr = @[index];
[self.firstPartTab reloadRowsAtIndexPaths:dexArr withRowAnimation:UITableViewRowAnimationNone];
// static dispatch_once_t disOnce;
// dispatch_once(&disOnce, ^ {
//
//
// });
}
//-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
// NSLog(@"address%@",result.address);
// self.address = result.address;
//
//
// NSIndexPath *index=[NSIndexPath indexPathForRow:4 inSection:0];
// NSArray *dexArr = @[index];
// [self.firstPartTab reloadRowsAtIndexPaths:dexArr withRowAnimation:UITableViewRowAnimationNone];
//
//// static dispatch_once_t disOnce;
//// dispatch_once(&disOnce, ^ {
////
////
//// });
//
//
//}
- (void)onGetGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
}
//- (void)onGetGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
//
//}
-(void)layoutSubviews{
@@ -380,7 +455,7 @@ BMKGeoCodeSearchDelegate>
cermod.shopAddress = detailLocation.detailLactionTextView.text;
}
_locService.delegate=nil;
// _locService.delegate=nil;
if (self.delegate) {
[self.delegate nextBtnClickAction:cermod];
}
@@ -44,6 +44,7 @@
self.bakbutton.frame = CGRectMake(0,0,48,44);
[self.bakbutton setImage:[UIImage imageNamed:@"arrow_b"] forState:UIControlStateNormal];
[self.bakbutton addTarget: self action: @selector(goBackAction) forControlEvents: UIControlEventTouchUpInside];
[self.bakbutton setContentEdgeInsets:UIEdgeInsetsMake(0, 10, 0, -10)];
self.back=[[UIBarButtonItem alloc] initWithCustomView:self.bakbutton];
self.navigationItem.leftBarButtonItem=self.back;
@@ -28,7 +28,7 @@
self.holdBackView.layer.cornerRadius = 10;
self.holdBackView.layer.shadowOffset = CGSizeZero;
self.holdBackView.layer.shadowOpacity = 0.8f;
UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:self.holdBackView.bounds];
self.holdBackView.layer.shadowPath = shadowPath.CGPath;
self.bootomLabel.textColor = RGB(153, 153, 153);
@@ -17,6 +17,7 @@ const float ActivityPageSize = 20;
@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,strong) NSMutableArray *dataArr;
@property (nonatomic,strong) NSMutableArray *activTypes;
@property (nonatomic,strong) UIView *sectionHeaderView;
@property (nonatomic) NSInteger firstResult;
@property(nonatomic,copy) NSString* total;
@property(nonatomic)BOOL isLoadMore;
@@ -87,7 +88,7 @@ const float ActivityPageSize = 20;
-(void)creatTab{
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height) style:UITableViewStyleGrouped];
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height-TOP_HEIGHT) style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.scrollEnabled = YES;
@@ -127,18 +128,27 @@ const float ActivityPageSize = 20;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if (section==0) {
return 0.01;
}else{
return 10;
}
return 10;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
return self.sectionHeaderView;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.01;
return CGFLOAT_MIN;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
return nil;
}
-(UIView *)sectionHeaderView{
if (!_sectionHeaderView) {
_sectionHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
}
return _sectionHeaderView;
}
-(void)creatReatRefreshView{
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@@ -16,18 +15,18 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="124"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="123"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="123.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="yCp-Pc-niT">
<rect key="frame" x="15" y="19" width="43" height="43"/>
<rect key="frame" x="23" y="22" width="43" height="43"/>
<constraints>
<constraint firstAttribute="height" constant="43" id="K1h-6R-dgq"/>
<constraint firstAttribute="width" constant="43" id="utS-Lc-5nb"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" usesAttributedText="YES" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MC2-dj-tQV">
<rect key="frame" x="15" y="70" width="43" height="21"/>
<rect key="frame" x="23" y="73" width="43" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="43" id="O0H-Fu-MQP"/>
<constraint firstAttribute="height" constant="21" id="spG-aM-uyY"/>
@@ -44,7 +43,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="j4H-3i-r5P">
<rect key="frame" x="66" y="19" width="44" height="21"/>
<rect key="frame" x="74" y="22" width="44" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="E4g-ow-Bbo"/>
</constraints>
@@ -53,7 +52,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="o4z-Rh-bJE">
<rect key="frame" x="66" y="44" width="31" height="15"/>
<rect key="frame" x="74" y="47" width="31" height="15"/>
<constraints>
<constraint firstAttribute="height" constant="15" id="ehn-eA-OyR"/>
</constraints>
@@ -62,14 +61,14 @@
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Rvn-dY-yD4" customClass="IFishActivityCateView">
<rect key="frame" x="207" y="13" width="113" height="18"/>
<rect key="frame" x="199" y="15.5" width="113" height="18"/>
<constraints>
<constraint firstAttribute="width" constant="113" id="prU-qW-zDS"/>
<constraint firstAttribute="height" constant="18" id="zt9-Kb-dri"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ncX-Ol-5UJ">
<rect key="frame" x="66" y="75" width="230" height="16"/>
<rect key="frame" x="74" y="78" width="214" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
@@ -178,7 +178,7 @@
-(void)creatTab{
self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight-TOP_HEIGHT) style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.scrollEnabled = YES;
@@ -278,14 +278,6 @@
return 70.0f;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 0.01f;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.01f;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
@@ -19,9 +19,12 @@
#define CELLTIJIAOBTN 6660660
#import "ChinaPlckerView.h"
#import "CertifyListFourthCell.h"
#import <BaiduMapAPI_Location/BMKLocationService.h>
#import <BaiduMapAPI_Search/BMKSearchComponent.h>
#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>
//#import <BaiduMapAPI_Location/BMKLocationService.h>
//#import <BMKLocationKit/BMKLocationComponent.h>
//#import <BaiduMapAPI_Search/BMKGeocodeSearch.h>
//#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>
//#import <BaiduMapAPI_Search/BMKGeocodeSearchResult.h>
#import <CoreLocation/CoreLocation.h>
#import "UIImageView+WebCache.h"
#import "ShopCertificationHtmlController.h"
@interface ShopEditViewController ()<UITableViewDelegate,
@@ -31,12 +34,13 @@
UIActionSheetDelegate,
UINavigationControllerDelegate,
ChinaPlckerViewDelegate,
BMKLocationServiceDelegate,
BMKGeoCodeSearchDelegate,
CLLocationManagerDelegate,
// BMKLocationServiceDelegate,
// BMKGeoCodeSearchDelegate,
UIGestureRecognizerDelegate>
{
BMKGeoCodeSearch*_geocodesearch;
// BMKGeoCodeSearch*_geocodesearch;
}
@@ -44,7 +48,9 @@
@property(nonatomic,strong) NSArray *titles;
@property(nonatomic,strong) NSArray *placeHolders;
@property(nonatomic,strong) NSString *address;
@property(nonatomic)BMKLocationService*locService;
//@property(nonatomic)BMKLocationService*locService;
@property (nonatomic,strong ) CLLocationManager *locationManager;//定位服务
@property (nonatomic,copy) NSString *currentCity;//城市
@property(nonatomic,strong) NSString *privence;
@property(nonatomic,strong) NSString *city;
@property(nonatomic,strong) NSString *area;
@@ -73,86 +79,182 @@
#pragma mark 定位
-(void)getLocation{
//初始化BMKLocationService
_locService=[[BMKLocationService alloc]init];
_locService.delegate=self;
//启动LocationService
[_locService startUserLocationService];
_geocodesearch=[[BMKGeoCodeSearch alloc]init];
// _locService=[[BMKLocationService alloc]init];
// _locService.delegate=self;
// //启动LocationService
// [_locService startUserLocationService];
// _geocodesearch=[[BMKGeoCodeSearch alloc]init];
// _geocodesearch.delegate=self;
if ([CLLocationManager locationServicesEnabled]) {
_locationManager = [[CLLocationManager alloc]init];
_locationManager.delegate = self;
[_locationManager requestAlwaysAuthorization];
_currentCity = [[NSString alloc]init];
[_locationManager requestWhenInUseAuthorization];
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
_locationManager.distanceFilter = 5.0;
[_locationManager startUpdatingLocation];
}
}
//处理方向变更信息
- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
{
//NSLog(@"heading is %@",userLocation.heading);
#pragma mark - 定位失败
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"请在设置中打开定位" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"打开定位" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSURL *settingURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication]openURL:settingURL];
}];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
[alert addAction:cancel];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
#pragma mark - 定位成功
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
[_locationManager stopUpdatingLocation];
CLLocation *currentLocation = [locations lastObject];
CLGeocoder *geoCoder = [[CLGeocoder alloc]init];
//当前的经纬度
NSLog(@"当前的经纬度 %f,%f",currentLocation.coordinate.latitude,currentLocation.coordinate.longitude);
//这里的代码是为了判断didUpdateLocations调用了几次 有可能会出现多次调用 为了避免不必要的麻烦 在这里加个if判断 如果大于1.0就return
NSTimeInterval locationAge = -[currentLocation.timestamp timeIntervalSinceNow];
if (locationAge > 1.0){//如果调用已经一次,不再执行
return;
}
//地理反编码 可以根据坐标(经纬度)确定位置信息(街道 门牌等)
[geoCoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {
if (placemarks.count >0) {
CLPlacemark *placeMark = placemarks[0];
_currentCity = placeMark.locality;
if (!_currentCity) {
_currentCity = @"无法定位当前城市";
}
//看需求定义一个全局变量来接收赋值
NSLog(@"当前国家 - %@",placeMark.country);//当前国家
NSLog(@"当前城市 - %@",_currentCity);//当前城市
NSLog(@"当前位置 - %@",placeMark.subLocality);//当前位置
NSLog(@"当前街道 - %@",placeMark.thoroughfare);//当前街道
NSLog(@"具体地址 - %@",placeMark.name);//具体地址
NSString *message = [NSString stringWithFormat:@"%@,%@,%@,%@,%@",placeMark.country,_currentCity,placeMark.subLocality,placeMark.thoroughfare,placeMark.name];
self.address =message;
CertifyListSecondCell *cell = [self.view viewWithTag:CELLMODYF_LOACTON];
if (cell) {
cell.loactionLabel.text= self.address;
}
static dispatch_once_t disOnce;
dispatch_once(&disOnce, ^ {
[self.tableView reloadData];
});
// UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:message delegate:self cancelButtonTitle:nil otherButtonTitles:@"好", nil];
// [alert show];
}else if (error == nil && placemarks.count){
NSLog(@"NO location and error return");
}else if (error){
NSLog(@"loction error:%@",error);
}
}];
}
//处理方向变更信息
//- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
//{
// //NSLog(@"heading is %@",userLocation.heading);
//}
//处理位置坐标更新
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
{
//- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
//{
//NSLog(@"didUpdateUserLocation lat %f,long %f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
[self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
// [self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
// static dispatch_once_t disOnce;
// dispatch_once(&disOnce, ^ {
//
// [self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
// });
}
//}
/**
* 地理反编码
*/
-(void)reverseGeoCodeWithlatitude:(CLLocationDegrees)latitude addlongitude:(CLLocationDegrees)longitude{
CLLocationCoordinate2D pt=(CLLocationCoordinate2D){latitude,longitude};
BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
reverseGeocodeSearchOption.reverseGeoPoint=pt;
BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
if(flag)
{
NSLog(@"反geo检索发送成功");
}
else
{
NSLog(@"反geo检索发送失败");
}
}
//-(void)reverseGeoCodeWithlatitude:(CLLocationDegrees)latitude addlongitude:(CLLocationDegrees)longitude{
// CLLocationCoordinate2D pt=(CLLocationCoordinate2D){latitude,longitude};
// BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
// reverseGeocodeSearchOption.reverseGeoPoint=pt;
// BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
// if(flag)
// {
// NSLog(@"反geo检索发送成功");
// }
// else
// {
// NSLog(@"反geo检索发送失败");
// }
//
//}
-(void)dealloc{
if (_geocodesearch!=nil) {
_geocodesearch=nil;
}
// if (_geocodesearch!=nil) {
// _geocodesearch=nil;
// }
}
#pragma mark BMKGeoCodeSearchDelegate
-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
NSLog(@"address%@",result.address);
self.address = result.address;
CertifyListSecondCell *cell = [self.view viewWithTag:CELLMODYF_LOACTON];
if (cell) {
cell.loactionLabel.text= self.address;
}
static dispatch_once_t disOnce;
dispatch_once(&disOnce, ^ {
[self.tableView reloadData];
});
}
//-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
// NSLog(@"address%@",result.address);
// self.address = result.address;
//
//
// CertifyListSecondCell *cell = [self.view viewWithTag:CELLMODYF_LOACTON];
//
// if (cell) {
//
// cell.loactionLabel.text= self.address;
//
// }
//
// static dispatch_once_t disOnce;
// dispatch_once(&disOnce, ^ {
//
// [self.tableView reloadData];
//
// });
//
//}
- (void)onGetGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
}
//返回地址信息搜索结果
//- (void)onGetGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error {
//
// if (error == BMK_SEARCH_NO_ERROR) {
// //在此处理正常结果
// }
// else {
// NSLog(@"抱歉,未找到结果");
// }
//}
//
//- (void)onGetGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
//
//
//}
-(void)goBackAction{
@@ -185,8 +287,8 @@
-(void)viewWillAppear:(BOOL)animated{
_geocodesearch.delegate=self;// 此处记得不用的时候需要置nil,
_locService.delegate=self;
// _geocodesearch.delegate=self;// 此处记得不用的时候需要置nil,
// _locService.delegate=self;
}
@@ -201,7 +303,7 @@
}
-(void)viewWillDisappear:(BOOL)animated{
_locService.delegate=nil;
// _locService.delegate=nil;
[super viewWillDisappear:animated];
@@ -32,7 +32,7 @@
-(void)setUI{
self.tableView = [[UITableView alloc] init ];
self.tableView.frame =CGRectMake(0,0, self.view.frame.size.width,self.view.frame.size.height);
self.tableView.frame =CGRectMake(0,0, self.view.frame.size.width,self.view.frame.size.height-TOP_HEIGHT);
self.tableView.delegate = self;
self.tableView.dataSource = self;
@@ -33,9 +33,9 @@
#import "ShopCertificationHtmlController.h"
#import "ChinaPlckerView.h"
#import <BaiduMapAPI_Location/BMKLocationService.h>
#import <BaiduMapAPI_Search/BMKSearchComponent.h>
#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>
//#import <BaiduMapAPI_Location/BMKLocationService.h>
//#import <BaiduMapAPI_Search/BMKSearchComponent.h>
//#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>
#import "UIImageView+WebCache.h"
@@ -44,6 +44,7 @@
#import "CertificationShopModel.h"
#import "CusomeCameraViewController.h"
#import "WFPhotosViewController.h"
#import <CoreLocation/CoreLocation.h>
//v4.4 后更改UI 此界面废弃
@interface ShopCertificationViewController ()<UITableViewDelegate,
UITableViewDataSource,
@@ -52,12 +53,12 @@
UITextFieldDelegate,
UINavigationControllerDelegate,
ChinaPlckerViewDelegate,
BMKLocationServiceDelegate,
BMKGeoCodeSearchDelegate,
CLLocationManagerDelegate,
// BMKGeoCodeSearchDelegate,
UIGestureRecognizerDelegate>
{
BMKGeoCodeSearch*_geocodesearch;
// BMKGeoCodeSearch*_geocodesearch;
}
@property(nonatomic,strong)UITableView *tableView;
@@ -66,13 +67,15 @@
@property(nonatomic,strong) NSArray *pictitles;
@property(nonatomic,strong)UIActionSheet*photosheet;
@property(nonatomic) NSInteger selectTag;
@property(nonatomic)BMKLocationService*locService;
//@property(nonatomic)BMKLocationService*locService;
@property(nonatomic,strong) NSString *privence;
@property(nonatomic,strong) NSString *city;
@property(nonatomic,strong) NSString *area;
@property(nonatomic,strong) NSString *address;
@property(nonatomic,strong) NSArray *textFeildTexts;
@property (nonatomic,strong ) CLLocationManager *locationManager;//定位服务
@property (nonatomic,copy) NSString *currentCity;//城市
@end
@@ -118,9 +121,9 @@
-(void)viewWillAppear:(BOOL)animated{
_geocodesearch.delegate=self;// 此处记得不用的时候需要置nil,
_locService.delegate=self;
// _geocodesearch.delegate=self;// 此处记得不用的时候需要置nil,
// _locService.delegate=self;
//
}
@@ -135,7 +138,7 @@
}
-(void)viewWillDisappear:(BOOL)animated{
_locService.delegate=nil;
// _locService.delegate=nil;
[super viewWillDisappear:animated];
@@ -149,86 +152,157 @@
#pragma mark 定位
-(void)getLocation{
//初始化BMKLocationService
_locService=[[BMKLocationService alloc]init];
_locService.delegate=self;
//启动LocationService
[_locService startUserLocationService];
_geocodesearch=[[BMKGeoCodeSearch alloc]init];
// _locService=[[BMKLocationService alloc]init];
// _locService.delegate=self;
// //启动LocationService
// [_locService startUserLocationService];
// _geocodesearch=[[BMKGeoCodeSearch alloc]init];
if ([CLLocationManager locationServicesEnabled]) {
_locationManager = [[CLLocationManager alloc]init];
_locationManager.delegate = self;
[_locationManager requestAlwaysAuthorization];
_currentCity = [[NSString alloc]init];
[_locationManager requestWhenInUseAuthorization];
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
_locationManager.distanceFilter = 5.0;
[_locationManager startUpdatingLocation];
}
}
//处理方向变更信息
- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
{
//NSLog(@"heading is %@",userLocation.heading);
}
//处理位置坐标更新
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
{
//NSLog(@"didUpdateUserLocation lat %f,long %f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
[self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
// static dispatch_once_t disOnce;
// dispatch_once(&disOnce, ^ {
//
// [self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
// });
#pragma mark - 定位失败
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"请在设置中打开定位" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"打开定位" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSURL *settingURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication]openURL:settingURL];
}];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
[alert addAction:cancel];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
#pragma mark - 定位成功
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
[_locationManager stopUpdatingLocation];
CLLocation *currentLocation = [locations lastObject];
CLGeocoder *geoCoder = [[CLGeocoder alloc]init];
//当前的经纬度
NSLog(@"当前的经纬度 %f,%f",currentLocation.coordinate.latitude,currentLocation.coordinate.longitude);
//这里的代码是为了判断didUpdateLocations调用了几次 有可能会出现多次调用 为了避免不必要的麻烦 在这里加个if判断 如果大于1.0就return
NSTimeInterval locationAge = -[currentLocation.timestamp timeIntervalSinceNow];
if (locationAge > 1.0){//如果调用已经一次,不再执行
return;
}
//地理反编码 可以根据坐标(经纬度)确定位置信息(街道 门牌等)
[geoCoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {
if (placemarks.count >0) {
CLPlacemark *placeMark = placemarks[0];
_currentCity = placeMark.locality;
if (!_currentCity) {
_currentCity = @"无法定位当前城市";
}
//看需求定义一个全局变量来接收赋值
NSLog(@"当前国家 - %@",placeMark.country);//当前国家
NSLog(@"当前城市 - %@",_currentCity);//当前城市
NSLog(@"当前位置 - %@",placeMark.subLocality);//当前位置
NSLog(@"当前街道 - %@",placeMark.thoroughfare);//当前街道
NSLog(@"具体地址 - %@",placeMark.name);//具体地址
NSString *message = [NSString stringWithFormat:@"%@,%@,%@,%@,%@",placeMark.country,_currentCity,placeMark.subLocality,placeMark.thoroughfare,placeMark.name];
self.address = message;
static dispatch_once_t disOnce;
dispatch_once(&disOnce, ^ {
[self.tableView reloadData];
});
}else if (error == nil && placemarks.count){
NSLog(@"NO location and error return");
}else if (error){
NSLog(@"loction error:%@",error);
}
}];
}
//处理方向变更信息
//- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
//{
// //NSLog(@"heading is %@",userLocation.heading);
//}
//处理位置坐标更新
//- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
//{
// //NSLog(@"didUpdateUserLocation lat %f,long %f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
// [self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
//// static dispatch_once_t disOnce;
//// dispatch_once(&disOnce, ^ {
////
//// [self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
//// });
//
//}
/**
* 地理反编码
*/
-(void)reverseGeoCodeWithlatitude:(CLLocationDegrees)latitude addlongitude:(CLLocationDegrees)longitude{
CLLocationCoordinate2D pt=(CLLocationCoordinate2D){latitude,longitude};
BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
reverseGeocodeSearchOption.reverseGeoPoint=pt;
BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
if(flag)
{
NSLog(@"反geo检索发送成功");
}
else
{
NSLog(@"反geo检索发送失败");
}
}
-(void)dealloc{
if (_geocodesearch!=nil) {
_geocodesearch=nil;
}
}
//-(void)reverseGeoCodeWithlatitude:(CLLocationDegrees)latitude addlongitude:(CLLocationDegrees)longitude{
// CLLocationCoordinate2D pt=(CLLocationCoordinate2D){latitude,longitude};
// BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
// reverseGeocodeSearchOption.reverseGeoPoint=pt;
// BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
// if(flag)
// {
// NSLog(@"反geo检索发送成功");
// }
// else
// {
// NSLog(@"反geo检索发送失败");
// }
//
//}
//-(void)dealloc{
//
// if (_geocodesearch!=nil) {
// _geocodesearch=nil;
// }
//}
#pragma mark BMKGeoCodeSearchDelegate
-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
NSLog(@"address%@",result.address);
self.address = result.address;
// CertifyListSecondCell *cell = [self.view viewWithTag:CERTYVIEW_CELLTAGROW6];
//
// if (cell) {
//
// cell.loactionLabel.text= result.address;
//
// }
static dispatch_once_t disOnce;
dispatch_once(&disOnce, ^ {
[self.tableView reloadData];
});
}
- (void)onGetGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
}
//-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
// NSLog(@"address%@",result.address);
// self.address = result.address;
//
//
//// CertifyListSecondCell *cell = [self.view viewWithTag:CERTYVIEW_CELLTAGROW6];
////
//// if (cell) {
////
//// cell.loactionLabel.text= result.address;
////
//// }
//
// static dispatch_once_t disOnce;
// dispatch_once(&disOnce, ^ {
//
// [self.tableView reloadData];
//
// });
//
//
//
//
//}
//
//- (void)onGetGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
//
//
//}
-(void)initData{