0

私の問題は本当に面倒です。写真を撮ってカスタムギャラリーに保存する必要があるアプリを作成しています。AlAssetsLibrary でこれを行う方法についていくつかのチュートリアルを見つけましたが、大きな問題が 1 つありますsaveImage:toAlbum:withCompletionBlock:。方法はありません。カスタム フォト アルバムを作成していましaddAssetsGroupAlbumWithName:resultBlock:failureBlock:たが、このギャラリーに画像を保存する方法がありません。iOS6のiPhone4を使用しています。

何か案は!?

4

3 に答える 3

1

質問で言及したメソッドはALAssetsLibrarysaveImage:toAlbum:withCompletionBlockの一部ではありません。このメソッドは、ALAssetLibary のカテゴリに記述されています。メソッドを使用するには、クラスにカテゴリをインポートする必要があります。

Objective C カテゴリの詳細については、開発者リファレンスをご覧ください。

于 2013-07-18T08:56:00.303 に答える
0

ここを見てください:

http://www.touch-code-magazine.com/ios5-saving-photos-in-custom-photo-album-category-for-download/

ここに Stackoverflow スレッドがあります: iPhone フォト ライブラリのカスタム アルバムに写真を保存する

于 2013-07-18T08:56:09.677 に答える
0

AssetsLibrary を使用している場合は、このコードを記述できます

- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    UIImagePickerController *imagePicker;

    if (buttonIndex < 2)    
    {           
        self.library = [[[ALAssetsLibrary alloc] init] autorelease];
        
        self.imageEditor = [[[DemoImageEditor alloc] initWithNibName:@"DemoImageEditor" bundle:nil] autorelease];
        
        self.imageEditor.doneCallback = ^(UIImage *editedImage, BOOL canceled){

            if(!canceled)
            {
                anotherImage = true;
                
                NSString *imageName;
               
                imageName =@"Abc.jpg";
                
                UIImageWriteToSavedPhotosAlbum(editedImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);      

                editedImage = [self scaleImage:editedImage toSize:CGSizeMake(600,600)];

                 [[NSUserDefaults standardUserDefaults] setObject:UIImagePNGRepresentation(editedImage)forKey:@"image"];

}

- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
    UIAlertView *alert;
    
        if (error)

        alert = [[UIAlertView alloc] initWithTitle:@"Error" 
                                           message:@"Unable to save image to Photo Album." 
                                          delegate:self cancelButtonTitle:@"Ok" 
                                 otherButtonTitles:nil];

    else 

        alert = [[UIAlertView alloc] initWithTitle:@"Success" 
                                           message:@"Image saved to Photo Album." 
                                          delegate:self cancelButtonTitle:@"Ok" 
                                 otherButtonTitles:nil];

    [alert release];
}

それはあなたのケースを解決します。

于 2013-07-18T08:57:15.883 に答える