
[英]swift 4, Using UIActivityViewController to share image to facebook and other app crashes
[英]App crashes when attempting to share image from app on facebook
我正在尝试将我的应用程序中的信息分享到Facebook。 当我在“图片”键中输入图片链接时,它运行良好,但是当我分享自己的一张图片时,应用程序崩溃。 这是我正在使用的代码
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Magic Photo from Abracadabra Snap!", @"name",@"Edit photos, move objects around,remove photo bombs", @"caption",@"Use automatic object detector to select objects or make your own custom selection.Remove the unwanted objects or photobomb,or move objects around.Do crazy stuff with your pictures , save and share with friends.", @"description",@"http://www.arkhitech.com/abracadabra/", @"link",tempImageForFacebookShare, @"picture",nil];
// Show the feed dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil parameters:params handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
{
if (error)
{
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog([NSString stringWithFormat:@"Error publishing story: %@", error.description]);
}
else {
if (result == FBWebDialogResultDialogNotCompleted)
{
// User cancelled.
NSLog(@"User cancelled.");
}
else
{
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:@"post_id"])
{
// User cancelled.
NSLog(@"User cancelled.");
}
else
{
// User clicked the Share button
NSString *result = [NSString stringWithFormat: @"Posted story, id: %@", [urlParams valueForKey:@"post_id"]];
NSLog(@"result %@", result);
}
}
}
}];
该图像为10 * 10图像, Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage length]: unrecognized selector sent to instance 0xab7b900'
错误为Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage length]: unrecognized selector sent to instance 0xab7b900'
。 请指导有关此问题
您的代码看起来有效,但是您正在将UIImage
发送到Facebook,在这里Facebook需要一个包含UIImages
的NSArray
。
请按以下方式更改您的NSDictionary
代码:
@[tempImageForFacebookShare], @"picture",
并查看它是否已解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.