2011-12-27 69 views
2

我使用使用Sharekit和IOS5嘰嘰喳喳,我使用它TWTweetComposeViewControllerClass類作爲,應用程序在iOS 4.X崩潰的框架Twitter.framework

Class TWTweetComposeViewControllerClass = NSClassFromString(@"TWTweetComposeViewController"); 

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

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



      [self.navigationController presentModalViewController:twitterViewController animated:YES]; 
      [twitterViewController release]; 
     } 
    } else { 
     [SHK flushOfflineQueue]; 
     SHKItem *item = [SHKItem text:text]; 
     //[SHKTwitter shareItem:item]; 
     SHKActionSheet *actionsheet = [SHKActionSheet actionSheetForItem:item]; 
     [actionsheet showFromToolbar:self.navigationController.toolbar]; 
    } 

這是工作的罰款與模擬5.0,但在崩潰4.3與以下錯誤。

dyld: Library not loaded: /System/Library/Frameworks/Twitter.framework/Twitter 
     Referenced from: /Users/indianic/Library/Application Support/iPhone Simulator/4.3.2/Applications/241167D0-62E0-4475-85FD-0B8253B4E456/demoFBTW.app/demoFBTW 
     Reason: image not found 

我該如何解決這個問題。 我試圖改變對框架的依賴關係需要可選但沒有找到那

+0

Twitter.framework只能擁有iOS中支持5不iOS4的 – iPhone 2011-12-27 06:47:13

+0

所以我將無法使用'TWTweetComposeViewControllerClass'爲應用程序使用ios5和ios4?因爲我爲 Heena 2011-12-27 06:48:29

+0

「使用sharekit」...但沒有找到「。 「你找不到那個」是什麼意思?你的意思是你在Xcode中找不到選項? – 2011-12-27 07:06:44

回答

3

它看起來像你發現如何弱鏈接框架。假設你正在使用的Xcode 4.2和LLVM3,你也可以簡化這個代碼位和修復你有一個錯誤,而你在它:

#include <Twitter/Twitter.h> 

// This line is no longer needed: 
// Class TWTweetComposeViewControllerClass = NSClassFromString(@"TWTweetComposeViewController"); 


// this part can now be: 
if ([TWTweetComposeViewController class] != nil) { // no need to look up class by string now 

    // note previously you were checking if this class responds to 'canSendTweet' 
    // but you never called the method to see if you can actually send the tweet 

    if([TWTweetComposeViewController canSendTweet]) { 

     // you can type this correctly now... 
     TWTweetComposeViewController *twitterViewController = [[TWTweetComposeViewController alloc] init]; 

     // ... and call this method directly 
     [twitterViewController setInitialText:NSLocalizedString(@"TwitterMessage", @"")]; 

     [self presentModalViewController:twitterViewController animated:YES]; 

     [twitterViewController release]; 
    } 
} 
... continue with the shareKit option