我在gifthub上找到了一个正是我想要的存储库。你能帮我解决一下如何使用单个按钮进行编码。我还没有足够的经验与ios programmin这样做。我差不多完成了我的第一个应用程序,但我需要帮助。
提前致谢
答案 0 :(得分:19)
对于初学者我建议这个.. 它更容易。只需几行代码。
- (IBAction)shareButtonPressed:(id)sender {
NSLog(@"shareButton pressed");
NSString *texttoshare = @"text to share";
UIImage *imagetoshare = [UIImage imageNamed:@"beck.png"];
NSArray *activityItems = @[texttoshare, imagetoshare];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes = @[UIActivityTypeAssignToContact, UIActivityTypePrint, UIActivityTypePostToTwitter, UIActivityTypePostToWeibo];
[self presentViewController:activityVC animated:TRUE completion:nil];
}