Подтвердить что ты не робот

TWTweetComposeViewController устарел в IOS6

Мой код работает как ожидалось, просто мне нужно избавиться от этого предупреждающего сообщения. TWTeetComposeViewController устарел в IOS6. Любая замена для этого встроенного контроллера в 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];
}
4b9b3361

Ответ 1

Есть некоторые изменения в использовании социальной сети между iOS 5 и iOS 6.
1. О библиотеке: в iOS 6 мы используем Social framework вместо Twitter   Фреймворк.
2. Мы используем SLComposeViewController вместо TWTweetComposeViewController.
3.Пожалуйста, сравните некоторые api со следующим кодом:

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

Есть только небольшие различия, но они более велики.

ПРЕДПОЧТЕНИЯ: - safilsunny Советы: http://www.mobile.safilsunny.com/integrating-facebook-ios-6/

Спасибо,

Ответ 2

Да, вы должны использовать Социальная структура на iOS 6. Это благодаря интеграции Facebook теперь присутствует на iOS. Вы сможете использовать Twitter и Facebook.