【发布时间】:2014-06-02 12:54:45
【问题描述】:
在给出重复标记之前阅读我的整个问题:
我知道可能有很多与我的标题相关的问题,但问题不同。
我正在使用 Mac OS X 10.9.3 和 Xcode 5.1.1。
在我的应用程序中,我只想在 Facebook 和 Twitter 上分享图片、URL 链接和一些描述,所以我使用了SLComposeViewController,我的代码如下。
-(void)btnShareTapped:(UIButton *)sender
{
if(sender.tag == 100)
[self shareProductContentOnTwitterORFB:@"Facebook"];
else
[self shareProductContentOnTwitterORFB:@"Twitter"];
}
方法体:
-(void) shareProductContentOnTwitterORFB:(NSString *) shareON
{
SLComposeViewController *shareKit = nil; // also tried with [[SLComposeViewController alloc] init];
if([shareON isEqualToString:@"Twitter"])
shareKit = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
else
shareKit = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[shareKit setInitialText:@"My Description Text."];
[shareKit addImage:[UIImage imageNamed:@"boston-shopping.jpg"]]; // I also tried with .png image
[shareKit addURL:[NSURL URLWithString:@"www.google.com"]];
//[self.view.window.rootViewController presentViewController:shareKit animated:YES completion:nil];
[self presentViewController:shareKit animated:YES completion:nil]; /// I also tried with above comment.
}
执行上述代码后,SLComposeViewController 将打开并在我的控制台中
<Error>: CGImageCreate: invalid image size: 0 x 0.
仅使用 Facebook 显示并得到完全相同的问题Look at this question.
我确定我的图片不是nil,我已经检查过了。
上面的问题说——
这个错误似乎已在新版本的 iOS (6.0.1) 中得到修复,至少自上次升级以来我一切正常。
但我在 iOS 6.1 上进行测试仍然遇到同样的问题,并且在 iOS 7.0 和 7.1 控制台中出现错误消息(<Error>: CGImageCreate: invalid image size: 0 x 0.) 不显示,但我无法在 Facebook 和 Twitter 中设置应用程序。
什么是问题?我错在哪里?这是苹果Bug吗??
请提出您的建议。
【问题讨论】:
-
你可以试一试吗:将
SLComposeViewController声明为属性并查看。 -
@Maulik - 试过了,不适合我:(
-
我想得到你的代码:)
-
所以尝试注释掉添加图像的行 - 有什么变化吗?尝试在 CGImageCreate() 上放置一个断点并查看堆栈的内容。如果做不到这一点,请构建一个有问题的小型演示应用程序,将其放在 Dropbox 上,并提供赏金以进行适当的修复。
-
重现该问题的最小项目将有助于...
标签: ios objective-c facebook cocoa-touch slcomposeviewcontroller