TWOSweetComposeViewController在IOS6中已弃用 [英] TWTweetComposeViewController deprecated in IOS6

查看:148
本文介绍了TWOSweetComposeViewController在IOS6中已弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码按预期工作只是因为我需要摆脱这条警告消息。
在IOS6中不推荐使用TWTeetComposeViewController。在ios6中替换这个内置视图控制器?

My code is working as expected just that I need to get rid of this warning message. TWTeetComposeViewController deprecated in IOS6. Any replacement for this built-in view controller in ios6?

这是我的示例代码。

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];
}


推荐答案

有一些变化在iOS 5和iOS之间使用社交网络iOS 6.


1.关于图书馆:在iOS 6中,我们使用社交框架而不是Twitter
Framework。


2.我们使用SLComposeViewController而不是TWTweetComposeViewController。


3.请将一些api与以下代码进行比较:

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");
    }

这只是一些差异,但它们更加出色。

There's just a little differences, but they're more great.

首选项:
- safilsunny提示: http://www.mobile.safilsunny.com/integrating-facebook-ios-6/

谢谢,

这篇关于TWOSweetComposeViewController在IOS6中已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆