2012-07-31 59 views
0

在Xcode 4.3進出口試圖從應用程序使用相機的照片,並使用從圖片庫的圖像或一個在這裏添加------->iphone相機上傳

(void) ShareButton { 
[AddThisSDK showAddThisButtonInView:self.view 
          withFrame:CGRectMake(75, 50, 150, 50) 
          forImage:[UIImage imageNamed:@"**HERE**"] 
          withTitle:@"Share Your Dinner" 
         description:@""]; 
} 

我的相機是完全的工作,我只是不知道如何讓映像名稱那裏,如果你需要任何更多的信息或一個更好的解釋隨便問

回答

0

相反的:

forImage:[UIImage imageNamed:@"**HERE**"] 

您應該使用這個:

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{ 
    UIImage *myImageFromCamera = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; 
    [AddThisSDK showAddThisButtonInView:self.view 
          withFrame:CGRectMake(75, 50, 150, 50) 
          forImage:myImageFromCamera 
          withTitle:@"Share Your Dinner" 
         description:@""]; 
} 

UIImagePickerController的didFinishPickingMediaWithInfo委託方法可用於檢測用戶何時按下在拾取器的‘使用’按鈕。如上所示,然後它爲用戶拍攝的圖像創建了一個UIImage,然後我們將該圖像設置爲AddThisSDK共享圖像。

請注意,這是過度簡化,並不會直接執行您想要的任何操作。爲了正確完成此操作,您需要全局聲明UIImage,以便您可以在didFinishPickingMediaWithInfo中設置圖像,然後稍後在AddThisSDK共享方法中調用它。

注:forImage:[UIImage imageNamed:@"**HERE**"]告訴它應該使用名爲「這裏」圖像的方法保存在您的應用程序包。

0
-(void)imagePickerController:(UIImagePickerController *)picker 
didFinishPickingMediaWithInfo:(NSDictionary *)info 
{ 
    UIImage *myImageFromCamera = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; 
    [AddThisSDK showAddThisButtonInView:self.view 
           withFrame:CGRectMake(75, 50, 150, 50) 
           forImage:myImageFromCamera 
           withTitle:@"Share Your Dinner" 
          description:@""]; 

    NSString *mediaType = [info 
          objectForKey:UIImagePickerControllerMediaType]; 
    [self dismissModalViewControllerAnimated:YES]; 
    if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { 
     UIImage *image = [info 
          objectForKey:UIImagePickerControllerOriginalImage]; 

     imageView.image = image; 
     if (newMedia) 
      UIImageWriteToSavedPhotosAlbum(image, 
              self, 
              @selector(image:finishedSavingWithError:contextInfo:), 
              nil); 
} 

這完美地工作,您採取或卷選擇與分享按鈕

+0

顯示出來。如果我的帖子幫你,那麼請把它標記爲正確答案的照片。 – 2012-07-31 15:20:17