iPhone:twitter working fine in ios4.3 but not working in ios5 with Twitter+OAuth

夙愿已清 提交于 2019-12-11 10:37:59

问题


In my iPhone App,

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.

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

do you have any idea?


回答1:


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

Add in your h file

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

And add the Twitter framework and Accounts as optional Libraries.



来源:https://stackoverflow.com/questions/9177476/iphonetwitter-working-fine-in-ios4-3-but-not-working-in-ios5-with-twitteroauth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!