地图二维码的扫描

首先 自动生成:
target ‘mapsaomiao’ do
pod ‘AMap3DMap’
pod ‘AMapSearch’
pod ‘AMapLocation’
pod ‘ZBarSDK’
end
在这里插入图片描述
开启权限:
Privacy - Location When In Use Usage Description 使用应用期间允许访问位置信息
Privacy - Location Usage Description 永不允许访问位置信息
Privacy - Location Always Usage Description 始终允许访问位置信息

然后在appdelegate.m里面写:
#import “AppDelegate.h”

#import <AMapFoundationKit/AMapFoundationKit.h>
@interface AppDelegate ()

@end

@implementation AppDelegate

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[AMapServices sharedServices] setEnableHTTPS:YES];
    [AMapServices sharedServices].apiKey = @“a5a335fcdb25ee5d71e94e78a9692e9b”;
    return YES;
    }

然后再在viewcontroller.m里面写:

#import “ViewController.h”
#import <MAMapKit/MAMapKit.h>
#import <AMapFoundationKit/AMapFoundationKit.h>
#import <UIKit/UIKit.h>
#import “ZBarSDK.h”
#define ScreenFrame [[UIScreen mainScreen]bounds]
@interface ViewController ()

@end

@implementation ViewController

  • (void)viewDidLoad {
    [super viewDidLoad];
    ///地图需要v4.5.0及以上版本才必须要打开此选项(v4.5.0以下版本,需要手动配置info.plist)
    [AMapServices sharedServices].enableHTTPS = YES;

    ///初始化地图
    MAMapView *_mapView = [[MAMapView alloc] initWithFrame:self.view.bounds];

    ///把地图添加至view
    [self.view addSubview:_mapView];

    ///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
    _mapView.showsUserLocation = YES;
    _mapView.userTrackingMode = MAUserTrackingModeFollow;

    MAUserLocationRepresentation *r = [[MAUserLocationRepresentation alloc] init];
    r.showsAccuracyRing = NO;///精度圈是否显示,默认YES
    r.showsHeadingIndicator = NO;///是否显示方向指示(MAUserTrackingModeFollowWithHeading模式开启)。默认为YES
    r.fillColor = [UIColor redColor];///精度圈 填充颜色, 默认 kAccuracyCircleDefaultColor
    r.strokeColor = [UIColor blueColor];///精度圈 边线颜色, 默认 kAccuracyCircleDefaultColor
    r.lineWidth = 2;///精度圈 边线宽度,默认0
    r.enablePulseAnnimation = NO;///内部蓝色圆点是否使用律动效果, 默认YES
    r.locationDotBgColor = [UIColor greenColor];///定位点背景色,不设置默认白色
    r.locationDotFillColor = [UIColor grayColor];///定位点蓝色圆点颜色,不设置默认蓝色
    r.image = [UIImage imageNamed:@“你的图片”]; ///定位图标, 与蓝色原点互斥
    [_mapView updateUserLocationRepresentation:r];

    UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, 595, self.view.frame.size.width, self.view.frame.size.height-160)];
    view.backgroundColor=[UIColor whiteColor];
    view.layer.cornerRadius=(self.view.frame.size.width)/2-10;
    view.layer.masksToBounds=YES;
    [self.view addSubview:view];

    UIButton *btn=[[UIButton alloc]initWithFrame:CGRectMake(155, 10, 100, 100)];
    [btn setImage:[UIImage imageNamed:@“2”] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:btn];
    }

-(void)click{
ZBarReaderViewController * reader = [ZBarReaderViewController new];//初始化相机控制器
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;//基本适配
reader.showsHelpOnFail = YES;
reader.scanCrop = CGRectMake(0, 0, 1, 1);
ZBarImageScanner * scanner = reader.scanner;
[scanner setSymbology:25 config:0 to:0];

[self presentViewController:reader animated:YES completion:nil];

}

@end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值