ios - Facebook 和 Twitter 分享按钮停止工作

标签 ios xcode facebook button share

<分区>

最近我可以使用它,但现在它突然停止了。按下这些按钮时不会执行任何操作。该代码甚至没有给出断点或错误。怎么了?

Download Project (3.2mb)

- (IBAction)ShareFB
{
    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
    {
        slComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
        [slComposeViewController addImage:[UIImage imageNamed:@"logo-carrito.png"]];
        [slComposeViewController addURL:[NSURL URLWithString:@"http://www.google.com"]];
        [self presentViewController:slComposeViewController animated:YES completion:NULL];
    }
    else {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No FB Account" message:@"There are no FB account registered. Configure one" delegate:nil cancelButtonTitle:@"Dissmiss" otherButtonTitles:nil];
        [alert show];
    }
}

- (IBAction)ShareTW
{
    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
    {
        slComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
        [slComposeViewController addImage:[UIImage imageNamed:@"logo-carito.png"]];
        [slComposeViewController addURL:[NSURL URLWithString:@"http://www.google.com"]];
        [self presentViewController:slComposeViewController animated:YES completion:NULL];
    }
    else {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No TW Account" message:@"There are no TW accounts registered. Configure one." delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
        [alert show];
    }
}

最佳答案

在你的 Storyboard中,你的第一个场景的类设置为ViewController,但实际上它显然应该是你的项目中包含的类之一,例如Tab1_ViewController

关于ios - Facebook 和 Twitter 分享按钮停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15011741/

上一篇:iphone - 如何使开关转移到另一个 View Controller ?

下一篇:ios - 修改二进制保存游戏数据 (iPhone)

相关文章:

ios - Swift iOS -NSMutableAttributedString 未呈现 ViewController?

ios - MFMailComposeViewController 在 iOS 4.3 上挂起应用程序

ios - 无法在SDK 3.2中保存Facebook accessToken

iphone - iOS - 使用 SDK 登录后在 webView 中登录

facebook graph api..获取 friend 的 friend

ios - 在类型为 'bounds' 的对象上找不到 UIAlertController 错误 '__strong id'

iphone - Tapku 日历演示在 xCode4/iOS5 中不工作

ios - 核心数据,enitityForName nil 错误

ios - 文档目标开始生成 "Objective-C garbage collection is no longer supported"

ios - 如何将 UIButton 的标题设置为左对齐?