UIActivityController behaviour different on device and simulator

假如想象 提交于 2019-12-01 11:41:49

Okay I have figured the problem.

The options shown in the UIActivityViewController totally depends on the type of items that are to be shared. For example, if there is a video, it will not show Facebook or twitter option. But if it's an image and title, it definitely will show the relevant options.

The following will show up apps like mail, twitter, Facebook, assignToContact, save to camera roll, print, copy, etc

// Create the content
NSString *message = @"The Upcoming App Scribble Talk";
UIImage *imageToShare = [UIImage imageNamed:@"createbtn.png"];

NSArray *objectsToShare = [NSArray arrayWithObjects:message, image, nil];

However, the following shall bring up only camera roll, mail or copy.

NSString *message = @"The Upcoming App Scribble Talk";
NSString *videoToShare = @"myFirsScribble.mov";
NSURL *videoPath = [NSURL fileURLWithPath:videoToShare];

NSArray *objectsToShare = [NSArray arrayWithObjects:message, videoPath, nil];

I think you want to show some certain service only in your UIActivityViewController. You may one property called excludedActivityTypes to be defined as below to avoid some default activity.

UIActivityViewController *yourvc = [[UIActivityViewController alloc]initWithActivityItems:[NSArray arrayWithObjects:img,nil] applicationActivities:[NSArray arrayWithObjects:nil]];
yourvc.excludedActivityTypes = @[UIActivityTypePostToWeibo,UIActivityTypePrint,UIActivityTypeMail,UIActivityTypeCopyToPasteboard];//Try this code in simulator.. you can only see FB & Twitter.  
        [self presentModalViewController:yourvc animated:YES];
        [avc release];

likewise you can excluded from default UIActivityViewController..

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!