簡體   English   中英

是否可以繼承TWTweetComposeViewController? 我在ios 6.0上崩潰

[英]Is it permited to inherit TWTweetComposeViewController? I have a crash on ios 6.0

我的應用程序可在裝有5.1(ipad)的設備上使用。 但是它在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?

在我看來,iOS 6將TWTweetComposeViewController隱式轉換為SLTwitterComposeViewController SLTwitterComposeViewController沒有任何setDelegateTwitter:方法。 這就是為什么會發生錯誤。

恕我直言

您的代碼將在iOS 5版本中運行。 因為您已經包含twitter.framework ,它將被替換為social.framework 因此,您需要檢查設備是iOS 6還是5 這里是一個鏈接,用於集成適用於iOS 5和iOS 6版本的twitter。

iOS 6社交框架

iOS 5 Twitter框架

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM