SLComposeViewController-SLServiceTypeTwitter,附加图像问题
下面是我使用SLComposeViewController在iOS应用程序中生成推文所面临的问题 首先,这是我的代码:SLComposeViewController-SLServiceTypeTwitter,附加图像问题,twitter,ios7,social-networking,attachment,Twitter,Ios7,Social Networking,Attachment,下面是我使用SLComposeViewController在iOS应用程序中生成推文所面临的问题 首先,这是我的代码: - (IBAction)twitButtonHandler:(id)sender { if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { SLComposeViewController *tweetController = [SLComposeVie
- (IBAction)twitButtonHandler:(id)sender
{
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewController *tweetController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
tweetController.completionHandler=nil;
[tweetController setInitialText:@"Hello this is a tweet."];
if (![tweetController addImage:[UIImage imageNamed:@"MyNicePicture.png"]]) {
NSLog(@"Unable to add the image!");
} else NSLog(@"Add the image OK!");
[self presentViewController:tweetController animated:YES completion:Nil];
} else {
// The device cannot send tweets.
NSLog(@"No Tweet possible!");
return;
}
}
上面的代码运行良好,除了我从未在实际tweet中看到图像,尽管它总是在调试器中显示消息“addtheimageok!”。有人能看到代码中有错误吗?或者告诉我哪里可能存在潜在问题?我自己深入研究这个问题,发现:
[UIImage imageNamed:@"MyNicePicture.png"]
结果是零
从这一点上,一切都得到了解释,问题与我获取UIImage对象的方式有关,而不是像我第一次想到的那样与SLComposeViewController和SLServiceTypeTwitter有关。您显示的代码只是显示了SLComposeViewController视图。在点击“发布”按钮之前,您是否在视图中看到附加的图像文件或以某种方式指示的图像文件?不,这正是问题所在:视图未附加。但是,如果我不发邮件,我可以看到图片在那里。我打赌这是因为你可以发JPG或GIF文件,但不能发png文件。