二維碼掃描

CIDetector 這個api是蘋果在ios8之后提供的。所以用蘋果自帶的AVFundation掃描,如果從相冊獲取圖片識別二維碼,則需要8.0系統(tǒng)以上。

- (void)viewDidLoad {

[super viewDidLoad];

_captureSession = nil;

//初始化掃描界面

[self setScanView];

}

-(void)viewWillAppear:(BOOL)animated {

//10.開始掃描

[_captureSession startRunning];

[self createTimer];

}

-(void)viewWillDisappear:(BOOL)animated {

[self stopTimer];

[self stopReading];

}

//二維碼的掃描區(qū)域

- (void)setScanView

{

self.view.backgroundColor = [UIColor clearColor];

UIView *scanView=[[UIView alloc] initWithFrame:CGRectMake(0,0, VIEW_WIDTH,VIEW_HEIGHT)];

[self.view addSubview:scanView];

_scanView = scanView;

_scanView.backgroundColor=[UIColor clearColor];

//最上部view

UIView* navView = [[UIView alloc] initWithFrame:CGRectMake(0,0, VIEW_WIDTH,SCANVIEW_EdgeTop - 40)];

navView.backgroundColor = kMainColorOfApp;

[_scanView addSubview:navView];

UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake((screenWith - 200)/2, 20, 200, 44)];

titleLabel.textColor = [UIColor whiteColor];

titleLabel.textAlignment = NSTextAlignmentCenter;

titleLabel.text = AppLocalizedString(@"Scan QR code");

[titleLabel setBackgroundColor:[UIColor clearColor]];

[navView addSubview:titleLabel];

//導(dǎo)航左邊的按鈕

UIButton *leftBarbtn = [[UIButton alloc] initWithFrame:CGRectMake(15, 30, 22, 22)];

[leftBarbtn setBackgroundImage:[UIImage imageNamed:@"back_normal_icon"] forState:UIControlStateNormal];

[leftBarbtn setBackgroundImage:[UIImage imageNamed:@"back_down_icon"] forState:UIControlStateHighlighted];

leftBarbtn.tag = kTagBtnLeft;

[leftBarbtn addTarget:self action:@selector(onBarbtnClick:) forControlEvents:UIControlEventTouchUpInside];

[navView addSubview:leftBarbtn];

//導(dǎo)航右邊的按鈕

UIButton *rightBarbtn = [[UIButton alloc] initWithFrame:CGRectMake(screenWith - 60 - 10, 20, 60, 44)];

[rightBarbtn setTitle:AppLocalizedString(@"Album") forState:UIControlStateNormal];

[rightBarbtn setTitle:AppLocalizedString(@"Album") forState:UIControlStateHighlighted];

rightBarbtn.tag = kTagBtnRight;

[rightBarbtn setTintColor:[UIColor blueColor]];

[rightBarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

[rightBarbtn addTarget:self action:@selector(onBarbtnClick:) forControlEvents:UIControlEventTouchUpInside];

[navView addSubview:rightBarbtn];

[self setReadView];

//最上部view

UIView* upView = [[UIView alloc] initWithFrame:CGRectMake(0,SCANVIEW_EdgeTop - 40, VIEW_WIDTH,40)];

upView.alpha = TINTCOLOR_ALPHA;

upView.backgroundColor = [UIColor blackColor];

[_scanView addSubview:upView];

//左側(cè)的view

UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0,SCANVIEW_EdgeTop, SCANVIEW_EdgeLeft,VIEW_WIDTH-2*SCANVIEW_EdgeLeft)];

leftView.alpha =TINTCOLOR_ALPHA;

leftView.backgroundColor = [UIColor blackColor];

[_scanView addSubview:leftView];

//右側(cè)的view

UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(VIEW_WIDTH-SCANVIEW_EdgeLeft,SCANVIEW_EdgeTop, SCANVIEW_EdgeLeft,VIEW_WIDTH-2*SCANVIEW_EdgeLeft)];

rightView.alpha =TINTCOLOR_ALPHA;

rightView.backgroundColor = [UIColor blackColor];

[_scanView addSubview:rightView];

//底部view

UIView *downView = [[UIView alloc] initWithFrame:CGRectMake(0,VIEW_WIDTH-2*SCANVIEW_EdgeLeft+SCANVIEW_EdgeTop,VIEW_WIDTH, VIEW_HEIGHT-(SCANVIEW_EdgeTop+VIEW_WIDTH-2*SCANVIEW_EdgeLeft))];

downView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:TINTCOLOR_ALPHA];

[_scanView addSubview:downView];

//用于說明的label

UILabel *labIntroudction= [[UILabel alloc] init];

labIntroudction.backgroundColor = [UIColor clearColor];

labIntroudction.frame=CGRectMake(0,5, VIEW_WIDTH,20);

labIntroudction.numberOfLines=1;

labIntroudction.font = [UIFont systemFontOfSize:15.0];

labIntroudction.textAlignment = NSTextAlignmentCenter;

labIntroudction.textColor = [UIColor whiteColor];

labIntroudction.text = AppLocalizedString(@"Align the QR Code within the frame to scan");

[downView addSubview:labIntroudction];

}

- (void)setReadView{

NSError *error;

//1.初始化捕捉設(shè)備(AVCaptureDevice),類型為AVMediaTypeVideo

AVCaptureDevice *captureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

//2.用captureDevice創(chuàng)建輸入流

AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:&error];

if (!input) {

CCLog(@"掃描錯誤%@", [error localizedDescription]);

return ;

}

//3.創(chuàng)建媒體數(shù)據(jù)輸出流

AVCaptureMetadataOutput *captureMetadataOutput = [[AVCaptureMetadataOutput alloc] init];

//4.實(shí)例化捕捉會話

_captureSession = [[AVCaptureSession alloc] init];

//高質(zhì)量采集率

[_captureSession setSessionPreset:AVCaptureSessionPresetHigh];

//4.1.將輸入流添加到會話

[_captureSession addInput:input];

//4.2.將媒體輸出流添加到會話中

[_captureSession addOutput:captureMetadataOutput];

//5.1.設(shè)置代理

[captureMetadataOutput setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];

//5.2.設(shè)置輸出媒體數(shù)據(jù)類型為QRCode

[captureMetadataOutput setMetadataObjectTypes:[NSArray arrayWithObject:AVMetadataObjectTypeQRCode]];

//6.實(shí)例化預(yù)覽圖層

AVCaptureVideoPreviewLayer *readerView = [[AVCaptureVideoPreviewLayer alloc] initWithSession:_captureSession];

_readerView = readerView;

//7.設(shè)置預(yù)覽圖層填充方式

[readerView setVideoGravity:AVLayerVideoGravityResizeAspectFill];

//8.設(shè)置圖層的frame

readerView.frame = CGRectMake(0,SCANVIEW_EdgeTop-40,screenWith,screenHeight-SCANVIEW_EdgeTop+40);

//9.將圖層添加到預(yù)覽view的圖層上

[_scanView.layer insertSublayer:readerView atIndex:0];

//10.設(shè)置掃描范圍

captureMetadataOutput.rectOfInterest = CGRectMake(0.2f, 0.2f, 0.8f, 0.8f);

//10.1.掃描框

UIImageView *boxView = [[UIImageView alloc] initWithFrame:CGRectMake(SCANVIEW_EdgeLeft,SCANVIEW_EdgeTop, VIEW_WIDTH-2*SCANVIEW_EdgeLeft,VIEW_WIDTH-2*SCANVIEW_EdgeLeft)];

_boxView = boxView;

boxView.image=[UIImage imageNamed:@"pick_bg.png"];

boxView.backgroundColor=[UIColor clearColor];

[_scanView addSubview:boxView];

//10.2.畫中間的掃描線

//? ? _QrCodeline = [[UIImageView alloc] initWithFrame:CGRectMake(SCANVIEW_EdgeLeft,SCANVIEW_EdgeTop, VIEW_WIDTH-2*SCANVIEW_EdgeLeft,5)];

_QrCodeline = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,_boxView.frame.size.width,5)];

[_QrCodeline setImage:[UIImage imageNamed:@"line.png"]];

_QrCodeline.backgroundColor = [UIColor clearColor];

[_boxView addSubview:_QrCodeline];

}

//二維碼的橫線移動

- (void)moveScanLayer

{

CGRect frame = _QrCodeline.frame;

if (_boxView.frame.size.height-3 <= _QrCodeline.frame.origin.y) {

frame.origin.y = 0;

_QrCodeline.frame = frame;

frame.origin.y = _boxView.frame.size.height-2;

[UIView beginAnimations:nil context:nil];? //開始動畫,第一個參數(shù)是該動畫的名字

[UIView setAnimationDuration:1.6f];? //動畫持續(xù)時間

_QrCodeline.frame = frame;

[UIView commitAnimations];? //結(jié)束動畫

}else{

frame.origin.y = _boxView.frame.size.height-2;

[UIView beginAnimations:nil context:nil];? //開始動畫,第一個參數(shù)是該動畫的名字

[UIView setAnimationDuration:1.6f];? //動畫持續(xù)時間

_QrCodeline.frame = frame;

[UIView commitAnimations];? //結(jié)束動畫

}

}

- (void)createTimer

{

//創(chuàng)建一個時間計(jì)數(shù)

_timer=[NSTimer scheduledTimerWithTimeInterval:1.6f target:self selector:@selector(moveScanLayer) userInfo:nil repeats:YES];

[_timer fire];

}

- (void)stopTimer

{

if ([_timer isValid] == YES) {

[_timer invalidate];

_timer =nil;

}

}

#pragma mark - AVCaptureMetadataOutputObjectsDelegate

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection

{

[_captureSession stopRunning];

//判斷是否有數(shù)據(jù)

if (metadataObjects != nil && [metadataObjects count] > 0) {

AVMetadataMachineReadableCodeObject *metadataObj = [metadataObjects objectAtIndex:0];

//判斷回傳的數(shù)據(jù)類型

if ([[metadataObj type] isEqualToString:AVMetadataObjectTypeQRCode]) {

[self readQRCodeActionWithCode:[metadataObj stringValue]];

}

}

}

-(void)stopReading{

[_captureSession stopRunning];

_captureSession = nil;

[_readerView removeFromSuperlayer];

[_QrCodeline removeFromSuperview];

}

/**

*? 識別出來二維碼之后的邏輯處理,以后有新的頁面調(diào)用掃描時直接在這個方法里面增加邏輯就可以了

*

*? @param symbolStr

*/

- (void)readQRCodeActionWithCode:(NSString *)symbolStr

{

if([symbolStr hasPrefix:kQrcodeFriend]){

NSRange range = [symbolStr rangeOfString:kQrcodeFriend options:NSCaseInsensitiveSearch];

if (range.location != NSNotFound && range.location == 0) {

NSString *userId = [symbolStr stringByReplacingCharactersInRange:range withString:@""];

self.requestType = NearbyServiceType;

[[NearbyService sharedInstance] serchFriendbyUserIdOrNumber:userId andTarget:self andSuccessSelector:self.successSelector andFailureSelector:self.failureSelector];

} else {

//錯誤提示

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:AppLocalizedString(@"AppName") message:AppLocalizedString(@"QR code error") delegate:self cancelButtonTitle:AppLocalizedString(@"OK") otherButtonTitles:nil, nil];

alert.tag = kTagAlertDismiss;

[alert show];

}

}else if ([symbolStr hasPrefix:kQrcodeBalance]){

NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:[[NSUserDefaults standardUserDefaults] objectForKey:GETWALLETINFO]];

NSMutableDictionary *dic1 = [dic objectForKey:[[CloudCall2AppDelegate sharedInstance] getUserID]];

NSNumber *isexist = [dic1 objectForKey:@"isexist"];

NSString *usertype = [dic1 objectForKey:@"usertype"];

NSRange range = [symbolStr rangeOfString:kQrcodeBalance options:NSCaseInsensitiveSearch];

if (range.location != NSNotFound && range.location == 0) {

if (!isexist.boolValue&&[usertype isEqualToString:@"V"]) {

[self showSetPayPasswordAlert];

}else if([usertype isEqualToString:@"M"]){

//錯誤提示

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:AppLocalizedString(@"Pay function is forbid for Merchant account .") delegate:nil cancelButtonTitle:AppLocalizedString(@"OK") otherButtonTitles: nil];

alert.tag = kTagAlertDismiss;

[alert show];

}else{

NSString *gid = [symbolStr stringByReplacingCharactersInRange:range withString:@""];

self.requestType = BalanceServiceType;

[[BalanceService sharedInstance] initOrderWithGid:gid andTarget:self andSuccessSelector:self.successSelector andFailureSelector:self.failureSelector];

}

} else {

//錯誤提示

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:AppLocalizedString(@"AppName") message:AppLocalizedString(@"QR code error") delegate:self cancelButtonTitle:AppLocalizedString(@"OK") otherButtonTitles:nil, nil];

alert.tag = kTagAlertDismiss;

[alert show];

}

}else if ([symbolStr hasPrefix:kQrcodeAd]){

//給服務(wù)端發(fā)送一個請求

self.requestType = ADPlatformServiceType;

//截取二維碼里面的廣告id(依據(jù)后臺服務(wù)端返回的協(xié)議)

NSArray *stringSeparateArr = [symbolStr componentsSeparatedByString:@"|"];

NSString *firstString = stringSeparateArr[0];

NSString *adIdString = [firstString substringFromIndex:4];//前面Adv# 這4個字符是固定的廣告二維碼標(biāo)識,后面緊跟的是廣告id

[[ADPlatformService sharedInstance] scanAdTwoDimensCodeWithADId:adIdString QrCode:symbolStr Target:self SuccessSelector:self.successSelector FailureSelector:self.failureSelector];

}else if ([symbolStr hasPrefix:kQrcodeWebLogin]){

//加密userid,格式化,再轉(zhuǎn)json

NSString *userId = [[CloudCall2AppDelegate sharedInstance] getUserID];

NSData *useridData = [userId dataUsingEncoding:NSUTF8StringEncoding];

NSString *userIdBase64 = [useridData base64Encoding];

NSString *userIdFormat = [NSString stringWithFormat:@"\"userid\":\"%@\"",userIdBase64];

//? ? ? ? NSString *userIdJson = [userIdFormat JSONString];

//格式化uuid

NSString *uuid = [symbolStr substringFromIndex:6];

NSString *uuidJson = [NSString stringWithFormat:@"\"uuid\":\"%@\"",uuid];

//格式化sessionid 再加密

NSString *sessionId = [NSString stringWithFormat:@"{%@,%@}",userIdFormat,uuidJson];

NSData *sessionIdData = [sessionId dataUsingEncoding:NSUTF8StringEncoding];

NSString *sessionIdBase64 = [sessionIdData base64Encoding];

//作為參數(shù)上送

NSDictionary *sessidDicParam = @{@"sessionId":sessionIdBase64};

if (self.qrCodeWebLoginParamDic == nil) {

self.qrCodeWebLoginParamDic = sessidDicParam;

}

[[AFHttpRequest instance] ASyncPOSTHTTPS:kScanQRCodeLoginUrl? andParameters:[sessidDicParam mutableCopy] andUserInfo:[NSMutableDictionary dictionaryWithObjectsAndKeys:@"scanQRCodeLogin",@"reqtype",nil] andTarget:self andSuccessSelector:@selector(scanQRCodeRequestSuccess:andResponse:) andFailureSelector:@selector(scanQRCodeRequestFailed:andError:)];

}else{

[self dismissViewControllerAnimated:NO completion:^{

if ([symbolStr rangeOfString:@".aero"].length>0||[symbolStr rangeOfString:@".arpa"].length>0||[symbolStr rangeOfString:@".biz"].length>0||[symbolStr rangeOfString:@".com"].length>0||[symbolStr rangeOfString:@".coop"].length>0||[symbolStr rangeOfString:@".edu"].length>0||[symbolStr rangeOfString:@".gov"].length>0||[symbolStr rangeOfString:@".info"].length>0||[symbolStr rangeOfString:@".int"].length>0||[symbolStr rangeOfString:@".jobs"].length>0||[symbolStr rangeOfString:@".mil"].length>0||[symbolStr rangeOfString:@".name"].length>0||[symbolStr rangeOfString:@".museum"].length>0||[symbolStr rangeOfString:@".nato"].length>0||[symbolStr rangeOfString:@".net"].length>0||[symbolStr rangeOfString:@".org"].length>0||[symbolStr rangeOfString:@".pro"].length>0||[symbolStr rangeOfString:@".cn"].length>0||[symbolStr rangeOfString:@".co"].length>0) {

[self OpenWebBrowser:symbolStr];

}else if ([symbolStr hasPrefix:@"http:"] || [symbolStr hasPrefix:@"https:"] || [symbolStr hasPrefix:@"www."]){

[self OpenWebBrowser:symbolStr];

}else{

HUD = [[MBProgressHUD alloc] initWithView:self.view];

[self.nav.view addSubview:HUD];

HUD.mode = MBProgressHUDModeCustomView;

HUD.labelText = AppLocalizedString(@"QR code error");

[HUD show:YES];

[HUD hide:YES afterDelay:2];

}

}];

}

}

#pragma mark - Action- (void)onBarbtnClick:(id)sender {? ? ? ? UIButton *btn = (UIButton *)sender;? ? ? ? if (btn.tag == kTagBtnLeft) {? ? ? ? ? ? ? ? [self dismissViewControllerAnimated:YES completion:nil];? ? ? ? ? ? } else if(btn.tag == kTagBtnRight) {? ? ? ? UIImagePickerController *picker = [[UIImagePickerController alloc] init];? ? ? ? picker.allowsEditing = YES;? ? ? ? picker.delegate = self;? ? ? ? picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;? ? ? ? [self presentViewController:picker animated:YES completion:^{}];? ? }}#pragma mark - UIImagePickerControllerDelegate- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{? ? if (SystemVersion < 8.0) {? ? ? ? ? ? ? ? [self imagePickerControllerForiOS7:picker didFinishPickingMediaWithInfo:info];? ? ? ? ? ? ? ? return;? ? ? ? }else{? ? ? ? ? ? ? ? //獲取用戶設(shè)備型號? ? ? ? BOOL isIphone4and5 = NO;? ? ? ? ? ? ? ? //如果不是iphone5以上設(shè)備(于如果沒有適配大屏,分辨率永遠(yuǎn)是568,這層攔截失效)? ? ? ? CGFloat height = [[UIScreen mainScreen] bounds].size.height;? ? ? ? ? ? ? ? if (height <= 568) {? ? ? ? ? ? ? ? ? ? ? ? //獲取用戶設(shè)備具體型號? ? ? ? ? ? struct utsname systemInfo;? ? ? ? ? ? ? ? ? ? ? ? uname(&systemInfo);? ? ? ? ? ? ? ? ? ? ? ? NSString *deviceString? ? ? ? ? ? = [NSString stringWithCString:systemInfo.machine? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? encoding:NSUTF8StringEncoding];? ? ? ? ? ? ? ? ? ? ? ? //iphone5/iphone5c/iphone4s設(shè)備? ? ? ? ? ? if ([deviceString isEqualToString:@" iPhone5,3"]||[deviceString isEqualToString:@"iPhone5,4"]||[deviceString isEqualToString:@"iPhone5,1"]||[deviceString isEqualToString:@"iPhone5,2"]||[deviceString isEqualToString:@"iPhone4,1"]) {? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? isIphone4and5 = YES;? ? ? ? ? ? }? ? ? ? }? ? ? ? ? ? if (isIphone4and5) {? ? ? ? ? ? ? ? ? ? ? ? [self imagePickerControllerForiOS7:picker didFinishPickingMediaWithInfo:info];? ? ? ? ? ? ? ? ? ? ? ? return;? ? ? ? }? ? }? ? ? ? //1.獲取選擇的圖片? ? UIImage * image = [info objectForKey:UIImagePickerControllerOriginalImage];? ? ? ? //2.初始化一個監(jiān)測器? ? CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:@{CIDetectorAccuracy:CIDetectorAccuracyHigh}];? ? ? ? [picker dismissViewControllerAnimated:YES completion:^{? ? ? ? ? ? ? ? //監(jiān)測到的結(jié)果數(shù)組? ? ? ? NSArray *features = [detector featuresInImage:[CIImage imageWithCGImage:image.CGImage]];? ? ? ? ? ? ? ? if (features.count >=1) {? ? ? ? ? ? ? ? ? ? ? ? /**結(jié)果對象 */? ? ? ? ? ? CIQRCodeFeature *feature = [features objectAtIndex:0];? ? ? ? ? ? NSString *scannedResult = feature.messageString;? ? ? ? ? ? ? ? ? ? ? ? if (scannedResult.length) {? ? ? ? ? ? ? ? [self readQRCodeActionWithCode:scannedResult];? ? ? ? ? ? ? ? ? ? ? ? ? ? } else {? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [[[UIAlertView alloc] initWithTitle:AppLocalizedString(@"AppName") message:AppLocalizedString(@"Decoding image file is not correct") delegate:nil cancelButtonTitle:AppLocalizedString(@"OK") otherButtonTitles:nil, nil]show];? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? }else {? ? ? ? ? ? ? ? ? ? ? ? [[[UIAlertView alloc] initWithTitle:AppLocalizedString(@"AppName") message:AppLocalizedString(@"Decoding image file is not correct") delegate:nil cancelButtonTitle:AppLocalizedString(@"OK") otherButtonTitles:nil, nil]show];? ? ? ? }? ? }];? ? ? ? [picker removeFromParentViewController];}- (void)imagePickerControllerForiOS7:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{? ? [picker dismissViewControllerAnimated:YES completion:^{? ? ? ? ? ? ? ? UIImage * image = [info objectForKey:UIImagePickerControllerOriginalImage];? ? ? ? ? ? ? ? //初始化? ? ? ? ZBarReaderController * read = [ZBarReaderController new];? ? ? ? ? ? ? ? //設(shè)置代理? ? ? ? read.readerDelegate = self;? ? ? ? CGImageRef cgImageRef = image.CGImage;? ? ? ? ZBarSymbol * symbol = nil;? ? ? ? idresults = [read scanImage:cgImageRef];

if ([info count]>2) {

int quality = 0;

for(ZBarSymbol *sym in results) {

int q = sym.quality;

if(quality < q) {

quality = q;

symbol = sym;

}

}

}else {

for(symbol in results)

break;

}

if (symbol != nil) {

NSString *symbolStr = [NSString stringWithCString:[symbol.data cStringUsingEncoding: NSShiftJISStringEncoding] encoding:NSUTF8StringEncoding];

[self readQRCodeActionWithCode:symbolStr];

//不用代理,統(tǒng)一在這里執(zhí)行

//? ? ? ? ? ? if(_codeScanDelegate && [_codeScanDelegate respondsToSelector:@selector(CodeScanFinishWith:andResultCode:)]) {

//? ? ? ? ? ? ? ? [_codeScanDelegate CodeScanFinishWith:self andResultCode:symbolStr];

//? ? ? ? ? ? }

} else {

[[[UIAlertView alloc] initWithTitle:AppLocalizedString(@"AppName") message:AppLocalizedString(@"Decoding image file is not correct") delegate:nil cancelButtonTitle:AppLocalizedString(@"OK") otherButtonTitles:nil, nil]show];

}

}];

[picker removeFromParentViewController];

}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker

{

[self dismissViewControllerAnimated:YES completion:^{}];

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 228,316評論 6 531
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 98,481評論 3 415
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 176,241評論 0 374
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 62,939評論 1 309
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 71,697評論 6 409
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 55,182評論 1 324
  • 那天,我揣著相機(jī)與錄音,去河邊找鬼。 笑死,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,247評論 3 441
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 42,406評論 0 288
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 48,933評論 1 334
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 40,772評論 3 354
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 42,973評論 1 369
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,516評論 5 359
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 44,209評論 3 347
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,638評論 0 26
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,866評論 1 285
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 51,644評論 3 391
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 47,953評論 2 373

推薦閱讀更多精彩內(nèi)容