Skip to content

Commit

Permalink
update,fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
MxABC committed Dec 15, 2015
1 parent 290e240 commit 2ed2c00
Show file tree
Hide file tree
Showing 29 changed files with 414 additions and 286 deletions.
101 changes: 55 additions & 46 deletions DemoTests/LBXScanDemo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
8 changes: 4 additions & 4 deletions DemoTests/LBXScanDemo/FirstViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import "FirstViewController.h"
#import "LBXScanViewController.h"
#import "SubLBXScanViewController.h"
#import "MyQRViewController.h"
#import "LBXScanView.h"
#import <objc/message.h>
Expand Down Expand Up @@ -116,7 +116,7 @@ - (void)qqStyle
UIImage *imgLine = [UIImage imageNamed:@"CodeScan.bundle/qrcode_scan_light_green"];
style.animationImage = imgLine;

LBXScanViewController *vc = [LBXScanViewController new];
SubLBXScanViewController *vc = [SubLBXScanViewController new];
vc.style = style;
vc.isQQSimulator = YES;
[self.navigationController pushViewController:vc animated:YES];
Expand Down Expand Up @@ -241,7 +241,7 @@ - (void)recoCropRect
style.animationImage = imgPartNet;


LBXScanViewController *vc = [LBXScanViewController new];
SubLBXScanViewController *vc = [SubLBXScanViewController new];
vc.style = style;
//开启只识别框内
vc.isOpenInterestRect = YES;
Expand Down Expand Up @@ -387,7 +387,7 @@ - (void)myQR

- (void)openScanVCWithStyle:(LBXScanViewStyle*)style
{
LBXScanViewController *vc = [LBXScanViewController new];
SubLBXScanViewController *vc = [SubLBXScanViewController new];
vc.style = style;
//vc.isOpenInterestRect = YES;
[self.navigationController pushViewController:vc animated:YES];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>


@interface UIActionSheet (Block)<UIActionSheetDelegate>
@interface UIActionSheet (LBXAlertAction)<UIActionSheetDelegate>


- (void)showInView:(UIView *)view block:(void(^)(NSInteger idx))block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
// Copyright © 2015年 lbxia. All rights reserved.
//

#import "UIActionSheet+Block.h"
#import "UIActionSheet+LBXAlertAction.h"
#import <objc/runtime.h>

static char key;

@implementation UIActionSheet (Block)
@implementation UIActionSheet (LBXAlertAction)


- (void)showInView:(UIView *)view block:(void(^)(NSInteger idx))block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import <UIKit/UIKit.h>


@interface UIAlertView (Block)
@interface UIAlertView (LBXAlertAction)

// 用Block的方式回调,这时候会默认用self作为Delegate
- (void)showWithBlock:(void(^)(NSInteger buttonIndex)) block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
// Copyright © 2015年 lbxia. All rights reserved.
//

#import "UIAlertView+Block.h"
#import "UIAlertView+LBXAlertAction.h"
#import <objc/runtime.h>

@implementation UIAlertView (Block)
@implementation UIAlertView (LBXAlertAction)


static char key;
Expand Down
12 changes: 8 additions & 4 deletions DemoTests/LBXScanDemo/LBXAlertAction/LBXAlertAction.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
//
// LBXAlertAction.h
//
// github:https://github.com/MxABC/LBXAlertAction
//
// Created by lbxia on 15/10/27.
// Copyright © 2015年 lbxia. All rights reserved.
//

#import <Foundation/Foundation.h>


/**
@brief 封装UIAlertView、UIActionSheet、UIAlertController
根据不同系统版本,对应选择,方便调用
*/
@interface LBXAlertAction : NSObject


Expand All @@ -17,7 +21,7 @@
@brief 模式对话框,选择一项(UIAlertView与与UIAlertController封装,根据不同ios版本对应选择调用方法)
@param title 标题
@param msg 提示内容
@param block 返回点击的按钮index
@param block 返回点击的按钮index,按照buttonsStatement按钮的顺序,从0开始
@param cancelString 取消按钮 文本,必须以nil结束
*/
+ (void)showAlertWithTitle:(NSString*)title msg:(NSString*)msg chooseBlock:(void (^)(NSInteger buttonIdx))block buttonsStatement:(NSString*)cancelString, ...;
Expand All @@ -30,8 +34,8 @@
@brief 显示UIActionSheet模式对话框,UIActionSheet与UIAlertController封装,根据不同ios版本对应选择调用方法。
@param title 标题
@param message 消息内容
@param block 返回block,buttonIdx:destructiveButtonTitle分别为0
otherButtonTitle从后面开始,如果destructiveButtonTitle没有,buttonIndex1开始,反之2开始,cancel是最后一个
@param block 返回block,buttonIdx:cancelString,destructiveButtonTitle分别为0、1,
otherButtonTitle从后面开始,如果destructiveButtonTitle没有,buttonIndex1开始,反之2开始
@param cancelString 取消文本
@param destructiveButtonTitle 特殊标记按钮,默认红色
@param otherButtonTitle 其他选项,必须以nil结束
Expand Down
42 changes: 32 additions & 10 deletions DemoTests/LBXScanDemo/LBXAlertAction/LBXAlertAction.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@

#import "LBXAlertAction.h"
#import <UIKit/UIKit.h>
#import "UIAlertView+Block.h"
#import "UIActionSheet+Block.h"
#import "UIAlertView+LBXAlertAction.h"
#import "UIActionSheet+LBXAlertAction.h"

@implementation LBXAlertAction


+ (BOOL)isIosVersion8AndAfter
{
// return NO;


return [[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0 ;
}

+ (void)showAlertWithTitle:(NSString*)title msg:(NSString*)message chooseBlock:(void (^)(NSInteger buttonIdx))block buttonsStatement:(NSString*)cancelString, ...
{

Expand All @@ -31,7 +39,7 @@ + (void)showAlertWithTitle:(NSString*)title msg:(NSString*)message chooseBlock:(
va_end(argList);
}

if ( [[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
if ( [LBXAlertAction isIosVersion8AndAfter])
{
//UIAlertController style

Expand Down Expand Up @@ -113,9 +121,11 @@ + (void)showAlertWithTitle:(NSString*)title msg:(NSString*)message chooseBlock:(
break;
}



[alertView showWithBlock:^(NSInteger buttonIdx)
{

block(buttonIdx);
}];

Expand Down Expand Up @@ -190,7 +200,7 @@ + (void)showActionSheetWithTitle:(NSString*)title message:(NSString*)message cho
return;
}

if (! [[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
if ( [LBXAlertAction isIosVersion8AndAfter] )
{
UIAlertController* alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleActionSheet];
for (int i = 0; i < [argsArray count]; i++)
Expand Down Expand Up @@ -264,12 +274,24 @@ + (void)showActionSheetWithTitle:(NSString*)title message:(NSString*)message cho
break;
}

[sheet showInView:view block:^(NSInteger idx)
{
if (block) {
block(idx);
}
}];
//
__block NSInteger maxIndex = otherButtonCount + (destructiveButtonTitle != nil ? 1:0) ;

[sheet showInView:view block:^(NSInteger buttonIdx)
{
NSInteger idx = buttonIdx;
if (maxIndex == buttonIdx) {
idx = 0;
}
else
{
idx = buttonIdx+1;
}

if (block) {
block(idx);
}
}];
}


Expand Down
44 changes: 44 additions & 0 deletions DemoTests/LBXScanDemo/SubLBXScanViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// SubLBXScanViewController.h
//
// github:https://github.com/MxABC/LBXScan
// Created by lbxia on 15/10/21.
// Copyright © 2015年 lbxia. All rights reserved.
//

#import "LBXAlertAction.h"
#import "LBXScanViewController.h"


//继承LBXScanViewController,在界面上绘制想要的按钮,提示语等
@interface SubLBXScanViewController : LBXScanViewController



#pragma mark -模仿qq界面

@property (nonatomic, assign) BOOL isQQSimulator;

/**
@brief 扫码区域上方提示文字
*/
@property (nonatomic, strong) UILabel *topTitle;



#pragma mark - 底部几个功能:开启闪光灯、相册、我的二维码
//底部显示的功能项
@property (nonatomic, strong) UIView *bottomItemsView;
//相册
@property (nonatomic, strong) UIButton *btnPhoto;
//闪光灯
@property (nonatomic, strong) UIButton *btnFlash;
//我的二维码
@property (nonatomic, strong) UIButton *btnMyQR;






@end
Loading

0 comments on commit 2ed2c00

Please sign in to comment.