你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS編程技術 >> iOS二維碼生成-libqrencode編譯報錯

iOS二維碼生成-libqrencode編譯報錯

編輯:IOS編程技術

libqrencode使用

1、將libqrencode文件夾整個拖入項目文件夾中

2、在要生成二維碼的頁面的 .m文件頭部添加 #import "QRCodeGenerator.h"

二維碼的view部分代碼

  UIView *downView = [[UIView alloc]initWithFrame:CGRectMake(15, 100, SCREEN_WIDTH-30, SCREEN_HEIGHT-200)];

    

    downView.tag = 10;

    

    downView.alpha = 0.9;

    

    downView.backgroundColor = TEXT_COLOR;

    

    UIImageView *downIOSView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, downView.frame.size.width, downView.frame.size.height-60)];

    

    downIOSView.backgroundColor = [UIColor whiteColor];

    

    UIImage *image = [QRCodeGenerator qrImageForString:detModel.down_ios imageSize:downIOSView.bounds.size.width];

    

    [downIOSView setImage:image];

    

    UIButton *dismissBtn = [[UIButton alloc]initWithFrame:downIOSView.frame];

    

    dismissBtn.backgroundColor = [UIColor clearColor];

    

    [dismissBtn addTarget:self action:@selector(dismissview:) forControlEvents:UIControlEventTouchUpInside];

    

    [downView addSubview:dismissBtn];

    

    [downView addSubview:downIOSView];

    

    [self.view addSubview:downView];

 

點擊二維碼彈出二維碼的view消失

-(void)dismissview:(UIButton *)sender

{

    

    for(UIView *subViews in [self.view subviews])

    {

        if(subViews.tag ==10)

        {

            [subViews removeFromSuperview];

        }

    }

}

 

3、編譯時QRCodeGenerator.h文件報錯

解決方法:在QRCodeGenerator.h頭部添加 #import <UIKit/UIKit.h>

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved