2013-03-27 73 views
8

我使用UIActivityViewController共享在iOS 6上的圖像和我的代碼UIActivityViewController不能添加圖像

 UIImage *shareImage = [UIImage imageNamed:@"myImage.png"]; 

     // Init array 
     NSMutableArray *items = [NSMutableArray new]; 
     [items addObject:@""]; 
     [items addObject:shareImage]; 

     // Add image to paste board 
     UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; 
     pasteboard.persistent = YES; 
     pasteboard.image = shareImage; 

     UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:items applicationActivities:nil]; 

     //This is an array of excluded activities to appear on the UIActivityViewController 
     activityVC.excludedActivityTypes = @[UIActivityTypePostToWeibo, 
              UIActivityTypePrint, 
              UIActivityTypeCopyToPasteboard, 
              UIActivityTypeAssignToContact, 
              UIActivityTypeSaveToCameraRoll]; 

     [self presentViewController:activityVC animated:TRUE completion:nil]; 

一切工作正常,但shareImage不能粘貼的iMessage到的iMessage。我不知道爲什麼? 感謝您的幫助!

+0

我不認爲你可以:http://stackoverflow.com/questions/12593255/compose-uiactivitytypemessage-with-uiimage – 2013-03-27 12:29:56

+1

文字只與行動表。你可以分享圖像與郵件和其他選項,如twitter Facebook等,但在iMessage中,它只允許文本。你可以查看可可控制其中一個可能有一個costum類,但只要行動表沒有運氣的人。 – 2013-03-27 23:40:19

+0

再次感謝:) – crz 2013-04-01 03:41:53

回答

1

正如其他人所說,iMessage只支持文本,而不是圖像。雖然聽起來像iOS7,但它確實有效。

我個人知道我已經得到它與OvershareKit合作:https://github.com/overshare/overshare-kit

這當然會增加一些開銷,但是可以讓您與他們的各種介質共享它們的漂亮界面/ API。

+0

這將接受蘋果在iTunes上上傳嗎?有沒有違反蘋果規則的代碼? – josh 2014-06-04 14:04:46

+0

是的。它目前被我的兩個應用程序接受和使用。 – valheru 2014-06-04 14:56:35