2014年4月24日木曜日

カメラロールに保存

[library writeImageToSavedPhotosAlbum:image.CGImage
                              orientation:(ALAssetOrientation)image.imageOrientation
                          completionBlock:
     ^(NSURL *assetURL, NSError *error){
         NSLog(@"URL:%@", assetURL);
         NSLog(@"error:%@", error);
         
         ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
         
         if (status == ALAuthorizationStatusDenied) {
             UIAlertView *alertView = [[UIAlertView alloc]
                                       initWithTitle:@"エラー"
                                       message:@"写真へのアクセスが許可されていません。\n設定 > 一般 > 機能制限で許可してください。"
                                       delegate:nil
                                       cancelButtonTitle:@"OK"
                                       otherButtonTitles:nil];
             [alertView show];
         } else {
             UIAlertView *alertView = [[UIAlertView alloc]
                                       initWithTitle:@""
                                       message:@"フォトアルバムへ保存しました。"
                                       delegate:nil
                                       cancelButtonTitle:@"OK"
                                       otherButtonTitles:nil];
             [alertView show];
         }

     }];

0 件のコメント:

コメントを投稿