我正在使用SLComposeViewController在我的应用程序中在Twitter和Facebook上共享。它适用于Twitter,但对于Facebook,SLComposeViewController会在选择位置时自动关闭。这是一个iOS 8问题。在iOS7上正常工作。
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
self.fbSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){
// [fbSheet dismissViewControllerAnimated:YES completion:nil];
switch(result){
case SLComposeViewControllerResultCancelled:
default:
{
NSLog(@"Cancelled.....");
}
break;
case SLComposeViewControllerResultDone:
{
NSLog(@"Posted....");
if([NetworkManager SharedInstance].isInternetReachable){
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Success"
message:@"Feeds shared successfully."
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}
break;
}};
[self.fbSheet setCompletionHandler:completionHandler];
NSString *fbString= self.titleString;
[self.fbSheet setInitialText:fbString];
[self.fbSheet addURL:[NSURL URLWithString:self.urlString]];
[self presentViewController:self.fbSheet animated:YES completion:nil];
}
控件自动进入完成处理程序块,结果取消。我已经通过一些帖子暗示它是64位架构问题。如果有人遇到同样的问题,请帮助我。
答案 0 :(得分:0)
- (IBAction)facebookPost:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
self.fbSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[self.fbSheet setInitialText:@"Social Framework test"];
[self.fbSheet addImage:[UIImage imageNamed:@"imagename.png"]];
[self.fbSheet addURL:[NSURL URLWithString:@"URL_NAME"]];
[self.fbSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
switch (result) {
case SLComposeViewControllerResultCancelled:
NSLog(@"Post Canceled");
break;
case SLComposeViewControllerResultDone:
{
NSLog(@"Post Sucessful");
NSLog(@"Posted....");
if([NetworkManager SharedInstance].isInternetReachable){
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Success"
message:@"Feeds shared successfully."
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}
break;
default:
break;
}
}];
[self presentViewController:self.fbSheet animated:YES completion:nil];
}
}