【问题标题】:iPhone:twitter working fine in ios4.3 but not working in ios5 with Twitter+OAuthiPhone:twitter 在 ios4.3 中运行良好,但在 ios5 中无法使用 Twitter+OAuth
【发布时间】:2012-02-28 22:52:15
【问题描述】:

在我的 iPhone 应用中,

我已经使用 Twitter+OAuth 库实现了 twitter 功能。它在 ios 4.3 中运行良好,但在 ios 5 中无法运行。 那么代码可能有什么问题。

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

你有什么想法吗?

【问题讨论】:

  • 使用这个链接http://stackoverflow.com/questions/9124521/iphone-twitter-sdk-integration-problems-with-ios-5-devices/9124813#9124813
  • 它工作正常..感谢您的早期响应..真的非常感谢....
  • 您可以通过单击网址上方左侧的复选标记将此答案标记为已接受的答案 - 这是感谢 Aript 的最佳方式。
  • 昨天已经完成了....祝您有美好的一天

标签: iphone objective-c xcode twitter twitter-oauth


【解决方案1】:

如果设备装有 iOS 5,我建议使用 TWTweetComposeViewController。

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 框架和帐户添加为可选库。

【讨论】:

    猜你喜欢
    • 2019-12-22
    • 2017-12-07
    • 2020-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多