gpt4 book ai didi

facebook - 通过 UIActivityViewController 将图像共享到 Facebook/Twitter 在 iOS 8 中停止工作

转载 作者:行者123 更新时间:2023-12-02 19:57:44 26 4
gpt4 key购买 nike

我在 iOS 7 的 FB/Twitter 中拥有完美工作的图像共享代码。

- (NSArray *)activityViewController:(NSArray *)activityViewController itemsForActivityType:(NSString *)activityType
{
...
if ([activityType isEqualToString:UIActivityTypePostToFacebook] ||
[activityType isEqualToString:UIActivityTypePostToTwitter])
return @[@"text", [UIImage imageNamed:@"myImage"]];
...
}

更新到 iOS 8 后,我只在发布窗口中看到空白图像,并且没有任何内容发布到社交网络。

想法?

最佳答案

这是我为视频共享所做的事情。您可以对图像进行相同的尝试。

我首先将视频数据保存到文档目录中的文件中,然后附加该文件。

//write to a file [videoData writeToFile:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/image.mov"] atomically:YES];

然后

- (IBAction)ShareVideoWihFacebook:(id)sender {
//get the file url NSString* path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/image.mov"];

NSURL *videoURL = [NSURL fileURLWithPath:path];
UIActivityViewController * activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[videoURL,@"Created by ..."] applicationActivities:NULL];

[activityVC setExcludedActivityTypes:@[ UIActivityTypeMail,UIActivityTypeAssignToContact, UIActivityTypeCopyToPasteboard, UIActivityTypePrint, UIActivityTypePostToWeibo,UIActivityTypeMessage,UIActivityTypeAirDrop,UIActivityTypeSaveToCameraRoll]];
[activityVC setValue:@"My Video" forKey:@"subject"];

[activityVC setCompletionHandler:^(NSString *activityType, BOOL completed) {
//NSLog(@"completed dialog - activity: %@ - finished flag: %d", activityType, completed);
}];

[self presentViewController:activityVC animated:TRUE completion:nil];
}

关于facebook - 通过 UIActivityViewController 将图像共享到 Facebook/Twitter 在 iOS 8 中停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26139782/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com