0

我创建了用于拍摄照片的自定义相册。我在我的应用程序中调用了这张专辑。单击按钮后,将调用相册。但我无法将这张图片分享到 Facebook。我使用社交框架进行分享。

代码:

photopick= [UIButton buttonWithType:UIButtonTypeCustom];
    [photopick setImage:[UIImage imageNamed:@"photo.png"] forState:UIControlStateNormal];
    // [overlayButton setFrame:CGRectMake(80, 420, 60, 30)];

    [photopick setFrame:CGRectMake(10, 10, 80, 50)];

    [photopick addTarget:self action:@selector(showAlbum:) forControlEvents:UIControlEventTouchUpInside];
    [[self view] addSubview:photopick];

-(void)showAlbum:(id)sender{

    imagePicker=[[UIImagePickerController alloc]init];

    imagePicker.delegate = self;

    imagePicker.allowsEditing =NO;

    imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

   // imagePicker.sourceType=UIImagePickerControllerSourceTypeSavedPhotosAlbum;


    [self presentModalViewController:imagePicker animated:YES];

}

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    //release picker
    [picker dismissModalViewControllerAnimated:YES];
}

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    //set image

    [self.navigationController.navigationBar setHidden:NO];




    //  newImage = [[UIImageView alloc] initWithImage:[info objectForKey:UIImagePickerControllerOriginalImage]];

    newImage = [[UIImageView alloc] initWithImage:[info objectForKey:UIImagePickerControllerOriginalImage]];

    [newImage setFrame:CGRectMake(0, 0, 320, 568)];

    //  [newImage setUserInteractionEnabled:YES];



    [self.view addSubview:newImage];

    // [newImage release];


    [picker dismissModalViewControllerAnimated:YES];

}

选择图片后,我有其他按钮可以将 newImage(专辑图片)分享到 facebook:

-(void)share:(id)sender{

if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
            SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

            [controller setInitialText:@"My Home Decoration"];
            [self presentViewController:controller animated:YES completion:Nil];
        }
}

但是我如何将专辑图像设置到 SLComposeViewController 内部。提到的一些文档在UIImage imageNamed:@"img.png"这里我没有 imageName。我有相册中的图片

4

0 回答 0