简体   繁体   English

iPhone Twitter SDK与iOS 5设备的集成问题

[英]iPhone Twitter SDK integration problems with iOS 5 devices

I have successfully integrated Twitter Sharekit with my iPad application source. 我已成功将Twitter Sharekit与我的iPad应用程序源集成在一起。 When I tested the app on simulator and iPad 1 with iOS 4.X it was working perfect and tweets were successfully posted. 当我在带有iOS 4.X的模拟器和iPad 1上测试该应用程序时,它运行良好,并且成功发布了推文。 But the same package if I install on iPad 2 with iOS 5, tweet can't be posted and it just shows Authorize app message continuously. 但是,如果我在装有iOS 5的iPad 2上安装了相同的软件包,则无法发布该推文,并且只会连续显示“授权应用”消息。 I can't find any other issue with this. 我找不到与此有关的任何其他问题。

Use the native Twitter available with the iOS 5 to integrate twitter. 使用iOS 5随附的本机Twitter集成Twitter。 On one hand the UI is fabulous and on the other you will not have any problem using SharKit. 一方面,UI很棒,另一方面,使用SharKit不会有任何问题。 Though I must tell you ShareKit is the best option for iOS versions below 5. 尽管我必须告诉您,ShareKit是低于5的iOS版本的最佳选择。

To use native Twitter integration do the following. 要使用本机Twitter集成,请执行以下操作。 Add these statements to the your class after including the necessary frameworks 包括必要的框架后,将这些语句添加到您的类中

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

Please note that when adding the Framework for Twitter and Accounts make sure they are set as optional. 请注意,添加Twitter和Accounts框架时,请确保将其设置为可选。

And then in you share method use the lines 然后在您的共享方法中使用以下行

- (void)shareOnTwitter {
Class TWTweetComposeViewControllerClass = NSClassFromString(@"TWTweetComposeViewController");

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

            [twitterViewController performSelector:@selector(setInitialText:) 
                                        withObject:twitterText];
            [twitterViewController performSelector:@selector(addURL:) 
                                        withObject:[NSURL URLWithString:url]];

            [twitterViewController performSelector:@selector(addImage:) 
                                        withObject:urImage];
            [self presentModalViewController:twitterViewController animated:YES];
            [twitterViewController release];
        }
else {
// Use ShareKit for previous versions of iOS
} 
}

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM