我正在使用SLComposeViewController发布到Twitter和Facebook.我对twitter和facebook都有相同的代码,但URL没有出现在twitter帖子中.我该如何解决?

Twitter代码 -
socialController = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeTwitter];
[socialController setInitialText:@"Testing: This is the app link!"];
[socialController addImage:[UIImage imageNamed:@"image.jpg"]];
[socialController addURL:[NSURL URLWithString:@"http://www.google.com"]];
[self presentViewController:socialController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
Facebook代码 -
socialController = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
[socialController setInitialText:@"Testing: This is the app link!"];
[socialController addImage:[UIImage imageNamed:@"image.jpg"]];
[socialController addURL:[NSURL URLWithString:@"http://www.google.com"]];
[self presentViewController:socialController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud) 嗨,我在iOS应用程序中有两个UIButton.一个是发布到Twitter,第二个是发布到Facebook.Facebook按钮工作得很好但是推文给我留下了一些问题,推文表将打开填充文本,但需要两次点击取消按钮才能解除.如果我点击发送,将发送推文并且表单被解雇,但我的应用程序冻结并变得无法响应.我已经包含了两位代码
- (IBAction)postTweet:(id)sender {
// if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]){
myTweet = [[SLComposeViewController alloc]init];
myTweet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
NSString *tweetString = [[NSString alloc]initWithFormat:@"%@\n%@\nvia @ValuatorApp", pdOne.text, pdTwo.text];
[myTweet setInitialText:tweetString];
[myTweet addURL:[NSURL URLWithString:@"http://sjb007.me/TheValuator"]];
[self presentViewController:myTweet animated:YES completion:nil];
// }
[myTweet setCompletionHandler:^(SLComposeViewControllerResult result) {
NSString *output = [[NSString alloc]init];
switch (result) {
case SLComposeViewControllerResultCancelled:
output = @"Twitter Post Cancelled";
break;
case SLComposeViewControllerResultDone:
output = @"Twitter post Succesful";
break;
default:
break;
}
NSLog(@"%@",output);
}];
}
- (IBAction)postFacebook:(id)sender {
// if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]){
myTweet = [[SLComposeViewController alloc]init]; …Run Code Online (Sandbox Code Playgroud) 我正在使用带有XCode 7 beta/iOS 9 beta的Social框架.Facebook应用程序安装在(物理)设备上,但在设置中,未配置任何帐户.根据文件:
要使帐户可用,用户必须在设备设置中登录社交服务.
但是,SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook)回归true.知道为什么会这样吗?
作为旁注:
let store = ACAccountStore()
let accountType = store.accountTypeWithAccountTypeIdentifier(ACAccountTypeIdentifierFacebook)
let accounts = store.accountsWithAccountType(accountType)
Run Code Online (Sandbox Code Playgroud)
未登录时,返回nil; 但登录后,返回一个空数组类型[AnyObject].
我有代码:
#import <Social/Social.h>
//...
//...
-(void)work {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[controller setInitialText:@"Its example text for Twitter"];
[controller addImage:[UIImage imageNamed:@"automobile"]];
[controller addURL:[NSURL URLWithString:@"http://www.auto.ru"]];
controller.completionHandler = ^(SLComposeViewControllerResult result) {
NSLog(@"*** %@", NSStringFromSelector(_cmd));
};
} else {
NSLog(@"The twitter service is not available");
}
}
Run Code Online (Sandbox Code Playgroud)
但我有警告:“SLServiceTypeTwitter”已弃用:在 iOS 11.0 中首次弃用
并记录:
...[core] isAvailableForServiceType: for com.apple.social.twitter returning NO
...The twitter service is not available
Run Code Online (Sandbox Code Playgroud)
希望我好吗?
我正在尝试使用IOS7实现Twitter帖子SLComposeViewController,我收到以下错误 -
由于与twitter的连接失败,因此无法发送推文"blah blah".
我在推文中包含图片和网址 - 如果这有什么不同的话......
代码如下 -
SLComposeViewController *composeController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[composeController setInitialText:@"i ran with 18 chickens under my armpits for 18 hours"];
[composeController addImage:[UIImage imageNamed:@"zoeLrg.png"]];
[composeController addURL: [NSURL URLWithString:
@"http://www.nme.com"]];
[self presentViewController:composeController
animated:YES completion:nil];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled) {
NSLog(@"delete");
} else
{
NSLog(@"post");
}
[composeController dismissViewControllerAnimated:YES completion:Nil];
};
composeController.completionHandler =myBlock;
Run Code Online (Sandbox Code Playgroud) 我有一张从相机中取出的图像并保存到/ tmp文件夹中.
当我将此图像添加到UIActivityViewController的activityItems,然后按下与Twitter或Facebook共享时,我必须等待最多20秒才能显示共享对话框.
请注意,我指的是为Twitter/Facebook显示的实际"发布"对话框,而不是生成它的本机共享弹出窗口.
当我从照片应用程序共享相同的图像时,它会立即显示.
起初我认为照片应用程序正在调整图像大小,因为较小的图像显得更快,但我发现当我使用SLComposeViewController直接将相同的图像分享到Twitter或Facebook时,它(几乎)立即出现.
假设我在代码中做错了,这就是导致冰冷的对话框出现的原因:
NSArray *items = @[@"foo", [UIImage imageWithContentsOfFile:@"valid path to test image"]];
UIActivityViewController *vc = [[UIActivityViewController alloc]
initWithActivityItems:items applicationActivities:nil];
[self presentViewController:vc animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
这几乎是立即起作用的:
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[controller setInitialText:@"foo"];
[controller addImage:[UIImage imageWithContentsOfFile:@"valid path to test image"]];
[self presentViewController:controller animated:YES completion:Nil];
Run Code Online (Sandbox Code Playgroud)
为了它的价值,我也尝试排除其他共享类型(我读过去AirDrop引起的问题),以及包装块以确保我在主线程上执行.
我想我做错了什么?
如果我不是,并且这两个其他方法实际上正在调整图像大小,是否有一些我缺少的文档提供了关于调整大小的指导?
**编辑:额外的测试似乎表明这个问题是iOS8独有的,因为我没有在较旧的iOS7设备上体验过它.
谢谢
objective-c ios slcomposeviewcontroller uiactivityviewcontroller
我注意到Mobile Safari的Twitter和Facebook共享添加了当前页面的屏幕截图而没有实际共享它,例如:

我试图通过SLComposeViewController复制它,但是调用addImage:实际上将UIImage添加到tweet/facebook相册(如预期的那样).
有没有办法只显示页面的屏幕截图而不添加图像?
编辑:看起来SLComposeViewController符合UIAppearanceContainer但是UI_APPEARANCE_SELECTOR没有记录.
objective-c ios ios6 slcomposeviewcontroller social-framework
我的应用程序中有一个按钮,可SLComposeViewController用于推特.当视图显示时,它会正确动画并消失.我发现它消失后会被发送到当前视图的后面,我无法将其恢复.我试过在代码中手动将所有视图发送到后面而没有运气.我觉得我的应用程序出现了根本性的错误,因为这种行为可以在任何级别上看到应用程序中的导航控制器.下面是SLComposeViewController应用程序中导航栏的截图,我让ViewController的视图有一个Alpha值0.0f来说明我的观点:

我真的不知道这里发生了什么,任何帮助将不胜感激.我用来呈现的代码SLComposeViewController是非常标准的,我已经在另一个应用程序中测试它并且工作正常:
NSString *message = [NSString stringWithFormat:@"#%@", [twitterInfo objectForKey:@"hashtag"]];
if ([appDelegate isSocialAvailable]) {
// code to tweet with SLComposeViewController
SLComposeViewController *twitter = [[SLComposeViewController alloc] init];
twitter = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[twitter setInitialText:[NSString stringWithFormat: @"%@", message]];
[self presentViewController:twitter animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud) 假设您希望在用户完成后执行某些操作.你是做什么?
它没有代表.一旦当前视图控制器被解除,该怎么办?
我正在使用SLComposeViewController进行Facebook共享,一切正常,除非我从Facebook应用程序从设备注销,然后调用SLComposeViewController isAvailableForServiceType:Facebook,它返回true并显示facebook post popup并在facebook警告之上'未登录'也显示出来.如果我点击该警报上的确定按钮,则执行完成块.感谢帮助.