2012-11-03 21 views
0

我的應用程序在5.1(ipad)的設備上運行。但它在6.0模擬器上墜毀。請查看錯誤。是否允許繼承TWTweetComposeViewController?我碰到了ios 6.0

@interface TwitterViewController : TWTweetComposeViewController 

@property (weak, nonatomic) id<TwitterVCDelegate> delegateTwitter; 

@end 

//在QuotesVC我打電話

TwitterViewController *tweetVC = [[TwitterViewController alloc] init]; 
tweetVC.delegateTwitter = self; 
[tweetVC postWithQuote:[quotesArray objectAtIndex:currentIndex]]; 

//我的應用程序崩潰

-[SLTwitterComposeViewController setDelegateTwitter:]: unrecognized selector sent to instance 0xa8d1bb0 
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SLTwitterComposeViewController setDelegateTwitter:]: unrecognized selector sent to instance 0xa8d1bb0' 
libc++abi.dylib: terminate called throwing an exception 

編輯工作一切良好,如果我不繼承TWTweetComposeViewController。

TWTweetComposeViewController *tweetSheet = 
    [[TWTweetComposeViewController alloc] init]; 
    [tweetSheet setInitialText:@"Initial Tweet Text!"]; 
    [self presentModalViewController:tweetSheet animated:YES]; 

我在ipad設備5.1和ios模擬器6.0上測試了這個代碼。它運作良好。

是否允許繼承TWTweetComposeViewController?

回答

1

在我腦海裏的iOS 6隱式轉換TWTweetComposeViewControllerSLTwitterComposeViewController一個環節。 SLTwitterComposeViewController沒有任何setDelegateTwitter:方法。這就是錯誤發生的原因。

恕我直言

0

您的代碼將在iOS 5版本中運行。因爲你已經包含twitter.framework,它將被替換爲social.framework所以你需要檢查設備是iOS 6還是5。這給Twitter整合的版本的iOS 5和iOS 6

iOS 6 Social framework

iOS 5 Twitter framework

+0

如果我添加social.framework到我的應用程序,我不會在iOS上運行5.1設備,因爲它有沒有這個框架。 – Voloda2

+0

http://stackoverflow.com/questions/6480765/how-do-i-weak-link-frameworks-on-xcode-4 http://stackoverflow.com/questions/7778104/problems-building-for-both- ios4-3-and-ios5-0這些鏈接對你有幫助。你需要將這兩個框架設置爲可選 –

+0

你試過,因爲我提到 –