在我的iPhone App中,
我已经在Twitter + OAuth库中实现了twitter功能。它在ios 4.3中工作正常,但在ios 5中不起作用。 那么代码可能会出现什么问题。
我想澄清我的应用的部署目标是4.3 ......
你知道吗?答案 0 :(得分:2)
如果设备有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框架和帐户添加为可选的库。