我在NSHipster上看到了这段代码,但它是如何被调用的?
- (id)activityViewController:(UIActivityViewController *)activityViewController
itemForActivityType:(NSString *)activityType
if ([activityType isEqualToString:UIActivityTypePostToFacebook])
{
return @"Like this!";
} else if ([activityType isEqualToString:UIActivityTypePostToTwitter]) {
return @"Retweet this!";
} else {
return nil;
}
}
我在这里找到了它:http://nshipster.com/uiactivityviewcontroller/
我也有这个叫:
- (void) shareFunction
NSString *textTitle = @"Hello";
NSString *text2 = _@"world";
UIImage *bestPhoto = [[UIImage alloc] initWithData: _photoData];
NSURL *website = [NSURL URLWithString:@"http://www.google.com/"];
NSArray *objectsToShare = @[textTitle, bestyText, bestPhoto, website];
NSArray *includeActivities = @[UIActivityTypeMessage,
UIActivityTypeMail,
UIActivityTypePostToFacebook,
UIActivityTypePostToTwitter,
UIActivityTypePostToFlickr];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
NSArray *excludeActivities = @[UIActivityTypeAirDrop,
UIActivityTypeCopyToPasteboard,
UIActivityTypePrint,
UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList,
UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo];
activityVC.excludedActivityTypes = excludeActivities;
[self presentViewController:activityVC animated:YES completion:nil];
}