我的代码按预期工作,只是我需要删除此警告消息.

这是我的示例代码.

if ([TWTweetComposeViewController canSendTweet]) {
    // Initialize Tweet Compose View Controller
    TWTweetComposeViewController *vc = [[TWTweetComposeViewController alloc] init];
    // Settin The Initial Text
    [vc setInitialText:@"This tweet was sent using the new Twitter framework available in iOS 5."];
    // Adding an Image
    UIImage *image = [UIImage imageNamed:@"sample.jpg"];
    [vc addImage:image];
    // Adding a URL
    NSURL *url = [NSURL URLWithString:@"http://mobile.tutsplus.com"];
    [vc addURL:url];
    // Setting a Completing Handler
    [vc setCompletionHandler:^(TWTweetComposeViewControllerResult result) {
        [self dismissModalViewControllerAnimated:YES];
    }];
    // Display Tweet Compose View Controller Modally
    [self presentViewController:vc animated:YES completion:nil];
} else {
    // Show Alert View When The Application Cannot Send Tweets
    NSString *message = @"The application cannot send a tweet at the moment. This is because it cannot reach Twitter or you don't have a Twitter account associated with this device.";
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oops" message:message delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
    [alertView show];
}

推荐答案

There're some change with using Social network between iOS 5 & iOS 6.
1. About library: in iOS 6 we use Social framework instead of Twitter Framework.
2. We use SLComposeViewController instead of TWTweetComposeViewController.
3.Please compare some api with the following code:

if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {

        SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];

        SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
            if (result == SLComposeViewControllerResultCancelled) {

                NSLog(@"Cancelled");

            } else

            {
                NSLog(@"Done");
            }

            [controller dismissViewControllerAnimated:YES completion:Nil];
        };
        controller.completionHandler =myBlock;

        //Adding the Text to the facebook post value from iOS
        [controller setInitialText:@"Test Post from mobile.safilsunny.com"];

        //Adding the URL to the facebook post value from iOS

        [controller addURL:[NSURL URLWithString:@"http://www.mobile.safilsunny.com"]];

        //Adding the Image to the facebook post value from iOS

        [controller addImage:[UIImage imageNamed:@"fb.png"]];

        [self presentViewController:controller animated:YES completion:Nil];

    }
    else{
        NSLog(@"UnAvailable");
    }

只是有点不同,但它们更伟大.

偏好:

谢谢

Objective-c相关问答推荐

核心数据 - 如何获取具有最大值属性的实体

定义缓存变量时在objective-c中使用static关键字

无法编译连接:错误是什么意思?

更改 UIDatePicker 字体 colored颜色 ?

从 Unix 时间戳创建 NSDate

将长格式的 NSString 拆分为多行

如何在 iOS SDK 中使用语音识别?

如何编写 Objective-C 完成块

如何在情节提要场景中嵌入自定义视图 xib?

如何将 .plist 文件中的数据 struct 读入 NSArray

StoryBoard 助理编辑器停止显示相关文件

从昨天开始无法将存档上传到应用store

如何在 NSSet 或 NSArray 中搜索具有特定属性的特定值的对象?

判断 NSString 是否仅包含字母数字 + 下划线字符

HTML 内容适合 UIWebview 而无需缩小

如何将 nil 添加到 nsmutablearray?

iOS 7 中的 UITextView 链接检测

BOOL到 NSString

目标 C:读取文本文件

有没有办法在用户已经在 iOS 上拒绝相机访问权限后向他们询问?