本文介绍了iPhone:twitter在ios4.3中工作正常,但在Twitter + OAuth的ios5中不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPhone应用程序中,

In my iPhone App,

我已经使用Twitter + OAuth库实现了twitter功能.在ios 4.3中工作正常,但在ios 5中不工作.那么代码可能是什么问题.

I have implemented twitter functionality with Twitter+OAuth library. It works fine in ios 4.3 but it does not work in ios 5.then what could be the problem with code.

我想澄清一下我的应用程序的部署目标是4.3 ...

I want to clarify that my app's deployment target is 4.3...

你有什么主意吗?

推荐答案

如果设备具有iOS 5,我建议使用TWTweetComposeViewController.

I recommend to use TWTweetComposeViewController if the device has iOS 5.

Class TWTweetComposeViewControllerClass = NSClassFromString(@"TWTweetComposeViewController");

     if (TWTweetComposeViewControllerClass != nil) {
      if([TWTweetComposeViewControllerClass respondsToSelector:@selector(canSendTweet)]) {
          UIViewController *twitterViewController = [[TWTweetComposeViewControllerClass alloc] init];

          [twitterViewController performSelector:@selector(setInitialText:)
                                      withObject:NSLocalizedString(@"TwitterMessage", @"")];
          [twitterViewController performSelector:@selector(addURL:)
                                      withObject:url];

           [twitterViewController performSelector:@selector(addImage:)
                                       withObject:[UIImage imageNamed:@"yourImage.png"]];
            [self.navigationController presentModalViewController:twitterViewController animated:YES];
            [twitterViewController release];
            }
        } else {
            [SHK flushOfflineQueue];
            SHKItem *item = [SHKItem URL:url title:NSLocalizedString(@"TwitterMessage", @"")];

            // Get the ShareKit action sheet
            SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];

            // Display the action sheet
            [actionSheet showInView:[self.view superview].window];
        }

添加您的h文件

#if defined(__IPHONE_5_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_5_0
#import <Twitter/Twitter.h>
#import <Accounts/Accounts.h>
#endif

并添加Twitter框架和Accounts作为可选库.

And add the Twitter framework and Accounts as optional Libraries.

这篇关于iPhone:twitter在ios4.3中工作正常,但在Twitter + OAuth的ios5中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 05:30