尝试使用ShareKit在Twitter上发布时接收错误 [英] Receive error when trying to post on Twitter using ShareKit

查看:177
本文介绍了尝试使用ShareKit在Twitter上发布时接收错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用sharekit在Twitter和Facebook上发布。



我有两个按钮可调用以下两种方法:

   - (IBAction)shareOnFacebook:(id)sender 
{
//创建要共享的项目
NSString * someText = @在Facebook上分享。
SHKItem * item = [SHKItem text:someText];

//分享项目
[[SHK currentHelper] setRootViewController:self.navigationController];
[SHKFacebook shareItem:item];
}

- (IBAction)shareOnTwitter:(id)sender
{
//创建要共享的项目
NSString * someText = @在推特上。;
SHKItem * item = [SHKItem text:someText];

//尝试了两种方法来设置navigationcontroller!
[[SHK currentHelper] setRootViewController:self.navigationController];
[SHK setRootViewController:self.navigationController];

[SHKTwitter shareItem:item];
}

Facebook只工作,当我尝试使用Twitter时,我得到以下错误:

  2011-05-31 10:20:25.928 App [870:707] ***  -  [SHK showViewController:],/Users/blaat/Dropbox/App/Classes/ShareKit/Core/SHK.m:112 
2011-05-31 10:20:25.975 App [870:707] ***终止应用程序到期到uncaught exception'NSInternalInconsistencyException',reason:'ShareKit:找不到根视图控制器。您可以通过调用[[SHK currentHelper] setRootViewController:YOURROOTVIEWCONTROLLER]手动分配一个。

因为我使用相同的方法为Facebook设置NavigationViewController其中一切正在工作...
我在SHKConfig.h中一次又一次检查所有变量




  • 验证OAuth

  • 应用程序类型浏览器

  • 回调url在config和dev中填写相同。 twitter.com

  • Consumerkey OK

  • Consumersecret OK



任何人有想法?



编辑。我启用了对Sharekit的调试,这是结果。我仍然不知道问题出在哪里。

  2011-06-01 09:07:28.496应用[179:707 ]< 0x2e9400 OAMutableURLRequest.m:(242)> OAMutableURLRequest参数oauth_consumer_key = ****************&安培; oauth_nonce = 9C826DA5-A991-4045-BA6C-96D62CF09AA0和放大器; oauth_signature_method = HMAC-SHA1和放大器; oauth_timestamp = 1306912048&安培; oauth_version = 1.0 
2011-06-01 09:07:30.109 App [179:707]< 0x2e4240 SHKOAuthSharer.m:(108)> tokenRequestTicket响应体:组oauth_token = tsuRQUGI63sE7XnRyxiNgy4G03ycUG7G0KhEjhROuw&安培; oauth_token_secret = jIsb6rqhqf11neREsIVrCnjy9i7epLhDKROmjgYJDmQ&安培; oauth_callback_confirmed = TRUE
2011-06-01 09:07:30.578应用[179:707] ***在断言失败 - [SHK showViewController:] /用户/blaat/Dropbox/App/Classes/ShareKit/Core/SHK.m:112
2011-06-01 09:07:30.774 App [179:707] ***由于未捕获异常终止应用程序'NSInternalInconsistencyException' ,原因:'ShareKit:找不到根视图控制器。你可以通过调用[[SHK currentHelper] setRootViewController:YOURROOTVIEWCONTROLLER]手动分配一个。
***首次调用堆栈:

0 CoreFoundation 0x33cd264f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x34115c5d objc_exception_throw + 24
2 CoreFoundation 0x33cd2491 + [NSException raise:format:arguments:] + 68
3基础0x34be4573 - [NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description: + 62
4应用程式0x0000bd5f - [SHK showViewController:] + 722
5应用程式0x0000fe87 - [SHKOAuthSharer tokenAuthorize] + 238
6应用程式0x0000fbb5 - [SHKOAuthSharer tokenRequestTicket:didFinishWithData:] + 396
7的CoreFoundation 0x33c42571 - [NSObject的(NSObject的)performSelector:withObject:withObject:] + 24
8应用0x00015cb5 - [OAAsynchronousDataFetcher connectionDidFinishLoading:] + 208
9基金会0x34ba02f5 - [NSURLConnection的(NSURLConnectionReallyInternal)sendDidFinishLoading] + 68
10基金会0x34ba0277 _NSURLConnectionDidFinishLoading + 78
11 CFNetwork的0x369ba411 _ZN19URLConnectionClient23_clientDidFinishLoadingEPNS_26ClientConnectionEventQueueE + 136
12 CFNetwork的0x369aef45 _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 100
13 CFNetwork的0x369af0cd _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 492
14 CFNetwork的0x369aee37 _ZN19URLConnectionClient13processEventsEv + 70
15 CFNetwork的0x369aede9 _ZN13URLConnection24multiplexerClientPerformEP18RunLoopMultiplexer + 36
16 CFNetwork的0x369aed5b _ZN17MultiplexerSource7performEv + 126
17 CFNetwork的0x369aecd9 _ZN17MultiplexerSource8_performEPv + 8
18的CoreFoundation 0x33ca9a79 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
19的CoreFoundation 0x33cab75f __CFRunLoopDoSources0 + 382
20的CoreFoundation 0x33cac4eb __CFRunLoopRun + 230
21的CoreFoundation 0x33c3cec3 CFRunLoopRunSpecific + 230
22的CoreFoundation 0x33c3cdcb CFRunLoopRunInMode + 58
23 GraphicsServices 0x347a541f GSEventRunModal + 114
24 GraphicsServices 0x347a54cb GSEventRun + 62
25 UIKit 0x33789d69 - [UIApplication _run] + 404
26 UIKit 0x33787807 UIApplicationMain + 670
27应用程序0x000023af main + 70
28应用程序0x00002364开始+ 40

编辑:我得到了答案

  [SHK setRootViewController:self.navigationController]; 

必须为:

  [SHK setRootViewController:self];问题是,它需要一个 UIViewController ,而我传递一个 UINavigationViewController 

解决方案

我们也使用ShareKit。我们尚未遇到此问题,但根据在线文档,ShareKit将尝试使用导航控制器堆栈找到你的根视图控制器,然后从那里弹出一个模态视图控制器。它会在找不到时抛出此错误。



您可以通过使用以下调用手动设置根视图控制器来更正它:

  [SHK setRootViewController:myViewController]; 


I'm trying to use sharekit to post on Twitter and Facebook.

I have two buttons which call the following two methods:

- (IBAction) shareOnFacebook:(id)sender
{
    // Create the item to share 
    NSString *someText = @"Share on Facebook.";
    SHKItem *item = [SHKItem text:someText];

    // Share the item
    [[SHK currentHelper] setRootViewController:self.navigationController];
    [SHKFacebook shareItem:item];
}

- (IBAction) shareOnTwitter:(id)sender
{
    // Create the item to share 
    NSString *someText = @"Share on Twitter.";
    SHKItem *item = [SHKItem text:someText];

    //tried both methods to set navigationcontroller!
    [[SHK currentHelper] setRootViewController:self.navigationController];
    [SHK setRootViewController:self.navigationController];  

    [SHKTwitter shareItem:item];
}

Facebook is working only, when I try to use Twitter I get the following error:

2011-05-31 10:20:25.928 App[870:707] *** Assertion failure in -[SHK showViewController:], /Users/blaat/Dropbox/App/Classes/ShareKit/Core/SHK.m:112
2011-05-31 10:20:25.975 App[870: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].'

Which is strange because I use the same method for Facebook to set the NavigationViewController where everything is working... I checked all the variables over and over again in the SHKConfig.h

  • Authentication OAuth
  • Application Type "Browser"
  • Callback url filled in the same in config and in dev.twitter.com
  • Consumerkey OK
  • Consumersecret OK

Anyone an idea?

Edit. I enabled debugging for Sharekit and this was the result. I still don't see where the problem is.

2011-06-01 09:07:28.496 App[179:707] <0x2e9400 OAMutableURLRequest.m:(242)> OAMutableURLRequest parameters oauth_consumer_key=****************&oauth_nonce=9C826DA5-A991-4045-BA6C-96D62CF09AA0&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1306912048&oauth_version=1.0
2011-06-01 09:07:30.109 App[179:707] <0x2e4240 SHKOAuthSharer.m:(108)> tokenRequestTicket Response Body: oauth_token=tsuRQUGI63sE7XnRyxiNgy4G03ycUG7G0KhEjhROuw&oauth_token_secret=jIsb6rqhqf11neREsIVrCnjy9i7epLhDKROmjgYJDmQ&oauth_callback_confirmed=true
2011-06-01 09:07:30.578 App[179:707] *** Assertion failure in -[SHK showViewController:], /Users/blaat/Dropbox/App/Classes/ShareKit/Core/SHK.m:112
2011-06-01 09:07:30.774 App[179: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].'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x33cd264f __exceptionPreprocess + 114
    1   libobjc.A.dylib                     0x34115c5d objc_exception_throw + 24
    2   CoreFoundation                      0x33cd2491 +[NSException raise:format:arguments:] + 68
    3   Foundation                          0x34be4573 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 62
    4   App                                 0x0000bd5f -[SHK showViewController:] + 722
    5   App                                 0x0000fe87 -[SHKOAuthSharer tokenAuthorize] + 238
    6   App                                 0x0000fbb5 -[SHKOAuthSharer tokenRequestTicket:didFinishWithData:] + 396
    7   CoreFoundation                      0x33c42571 -[NSObject(NSObject) performSelector:withObject:withObject:] + 24
    8   App                                 0x00015cb5 -[OAAsynchronousDataFetcher connectionDidFinishLoading:] + 208
    9   Foundation                          0x34ba02f5 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 68
    10  Foundation                          0x34ba0277 _NSURLConnectionDidFinishLoading + 78
    11  CFNetwork                           0x369ba411 _ZN19URLConnectionClient23_clientDidFinishLoadingEPNS_26ClientConnectionEventQueueE + 136
    12  CFNetwork                           0x369aef45 _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 100
    13  CFNetwork                           0x369af0cd _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 492
    14  CFNetwork                           0x369aee37 _ZN19URLConnectionClient13processEventsEv + 70
    15  CFNetwork                           0x369aede9 _ZN13URLConnection24multiplexerClientPerformEP18RunLoopMultiplexer + 36
    16  CFNetwork                           0x369aed5b _ZN17MultiplexerSource7performEv + 126
    17  CFNetwork                           0x369aecd9 _ZN17MultiplexerSource8_performEPv + 8
    18  CoreFoundation                      0x33ca9a79 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
    19  CoreFoundation                      0x33cab75f __CFRunLoopDoSources0 + 382
    20  CoreFoundation                      0x33cac4eb __CFRunLoopRun + 230
    21  CoreFoundation                      0x33c3cec3 CFRunLoopRunSpecific + 230
    22  CoreFoundation                      0x33c3cdcb CFRunLoopRunInMode + 58
    23  GraphicsServices                    0x347a541f GSEventRunModal + 114
    24  GraphicsServices                    0x347a54cb GSEventRun + 62
    25  UIKit                               0x33789d69 -[UIApplication _run] + 404
    26  UIKit                               0x33787807 UIApplicationMain + 670
    27  App                                 0x000023af main + 70
    28  App                                 0x00002364 start + 40
)

Edit: I got the answer

[SHK setRootViewController:self.navigationController];

needs to be:

[SHK setRootViewController:self];

Problem was that it needed a UIViewController, while I was passing a UINavigationViewController.

解决方案

We use ShareKit as well. We haven't run across this one yet, but according to the docs online, ShareKit will try to use the navigation controller stack to find your root view controller, then pop a modal view controller from there. It throws this error when it can't find one.

You can correct it by manually setting the root view controller by using the following call:

[SHK setRootViewController:myViewController];

这篇关于尝试使用ShareKit在Twitter上发布时接收错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆