2013-10-01 48 views
1

我使用UIActivityViewController允許通過郵件,Facebook,Twitter和SMS進行共享。我有以下代碼:ios - UIActivityViewController:SMS選項不顯示

-(void) aFunction 
{ 
NSString *textToShare = appRecord.title; 
UIImage *imageToShare = [UIImage imageNamed:@"test/png"]; 
NSURL *url = [NSURL URLWithString:@"http://www.stackoverflow.com"]; 
NSArray *activityItems = [[NSArray alloc] initWithObjects:textToShare, imageToShare,url,nil]; 


UIActivity *activity = [[UIActivity alloc] init]; 

NSArray *applicationActivities = [[NSArray alloc] initWithObjects:activity, nil]; 
UIActivityViewController *activityVC = 
[[UIActivityViewController alloc] initWithActivityItems:activityItems 
            applicationActivities:applicationActivities]; 

activityVC.excludedActivityTypes = @[UIActivityTypePostToWeibo, UIActivityTypeAssignToContact, UIActivityTypePrint ,UIActivityTypeCopyToPasteboard,UIActivityTypeAssignToContact,UIActivityTypeSaveToCameraRoll,UIActivityTypeMessage ]; 

[self presentViewController:activityVC animated:YES completion:nil]; 
[activityItems release]; 
[activity release]; 
[applicationActivities release]; 
[activity release]; 
} 

的代碼產生如下:

http://s24.postimg.org/tas3zo9w5/Screen_Shot_2013_10_01_at_5_09_26_PM.png

短消息服務選項丟失。我做錯了什麼?

回答

3

您排除UIActivityTypeMessage(excludedActivityTypes)。這隱藏了消息(SMS/iMessage)選項

+0

OMG,我想隱藏。 – Ketan

+5

另一件事是該設備必須具備短信功能才能顯示該選項。 – Ketan

+1

謝謝@Ketan。我想知道爲什麼模擬器沒有顯示這個選項,但我的QA設備是。 – JAL