我有一个UIActivityViewController在 Facebook/Twitter/Email 上共享文本和图像,但它只适用于 iOS 6+ .. 是否可以选择设备上运行的 iOS 版本并执行 IF 语句以避免崩溃iOS 5 ? 如果是 iOS6,请执行以下代码,否则执行其他操作...?
-(void)shareMenu
{
NSString *textToShare = @"Text that will be shared";
UIImage *imageToShare = [UIImage imageNamed:@"share_picture.png"];
NSArray *itemsToShare = [[NSArray alloc] initWithObjects:textToShare, imageToShare, nil];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
activityVC.excludedActivityTypes = [[NSArray alloc] initWithObjects: UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll, UIActivityTypeMessage, UIActivityTypePostToWeibo, nil];
[self presentViewController:activityVC animated:YES completion:nil];
}