App crashes after authentication Twitter using Sharekit
In our App we are using ShareKit to publish something on Facebook and Twitter. Facebook works perfectly, only there are some problems with Twitter.
The first time you want to send something using Twitter, you need to authenticate the app. This process also works fine only when it's done it should return to the screen to post on Twitter. But at this point the app crashes because it can't find the UIViewController anymore... See the following error:
2011-06-22 17:18:29.355 asdf[189:707] *** Assertion failure in -[SHK showViewController:], /Users/nvt/Documents/asdf/Classes/Core/SHK.m:117
2011-06-22 17:18:29.460 asdf[189:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'ShareKit: Could not find a root view controller. You can assign one manually by calling [[SHK currentHelper] setRootViewController:YOURROOTVIEWCONTROLLER].'
But I do set the UIViewController:
- (IBAction) shareAll:(id)sender
{
[SHK setRootViewController:self];
SHKItem *item = [SHKItem text:@"Deel app test"];
[SHK setFavorites:[NSArray arrayWithObjects:@"SHKTwitter", @"SHKFacebook",nil] forType:SHKShareTypeURL];
[SHK setFavorites:[NSArray arrayWithObjects:@"SHKTwitter", @"SHKFacebook",nil] forType:SHKShareTypeText];
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
actionSheet.title = @"Deel";
开发者_Python百科 [actionSheet showInView:self.view];
}
It seems that somehow Sharekit loses the handle on the UIViewController. I tried fixing it by adding:
[SHK setRootViewController:self];
To the ViewDidLoad and ViewWillAppear methods, but this didn't work. Anyone who encountered the same problem, or have an idea to fix this? Although the app crashes the authentication works, because the next time you want to post something on Twitter it does work. So it only crashes once during the first authentication...
ps. Using OAuth for Twitter
Edit: Answer Thx to Eimantas
I had to do two things to fix the problem:
- Define [SHK setRootViewController:(the main rootviewcontroller)] in the app delegate
- Use this fork from github https://github.com/rs/ShareKit/commit/2121cbc1a2d935b36921ae226449b2acd6f10c06#diff-0
Thx to Eimantas
I had to do two things to fix the problem:
- Define [SHK setRootViewController:(the main rootviewcontroller)] in the app delegate
- Use this fork from github https://github.com/rs/ShareKit/commit/2121cbc1a2d935b36921ae226449b2acd6f10c06#diff-0
精彩评论