2011-05-31 24 views
5

Estoy tratando de usar sharekit para publicar en Twitter y Facebook.Recibo un error al intentar publicar en Twitter usando ShareKit

tengo dos botones que llaman a los dos métodos siguientes:

- (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 está trabajando solamente, cuando trato de usar Twitter me sale el siguiente 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].' 

lo cual es extraño porque Utilizo el mismo método para Facebook para configurar el NavigationViewController donde todo está funcionando ... Revisé todas las variables una y otra vez en el SHKConfig.h

  • autenticación OAuth
  • Solicitud Tipo "explorador"
  • devolución de llamada URL llenado de la misma en la configuración y en dev.twitter.com
  • Consumerkey OK
  • Consumersecret OK

Cualquiera una ¿idea?

Editar. Permití la depuración de Sharekit y este fue el resultado. Todavía no veo dónde está el problema.

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 
) 

Editar: Tengo la respuesta

[SHK setRootViewController:self.navigationController]; 

necesita ser:

[SHK setRootViewController:self]; 

El problema era que necesitaba una UIViewController, mientras que yo estaba pasando un UINavigationViewController.

Respuesta

3

Usamos ShareKit también. Todavía no nos hemos encontrado con este, pero según el docs online, ShareKit intentará usar la pila del controlador de navegación para encontrar su controlador de vista raíz, y luego mostrar un controlador de vista modal desde allí. Lanza este error cuando no puede encontrar uno.

Usted puede corregir manualmente ajustando el controlador de vista raíz mediante la siguiente llamada:

[SHK setRootViewController:myViewController]; 
+0

Estaba haciendo eso solo estaba pasando un UINavigationViewController en lugar de un UIViewController – Slaapyhoofd

2

Editar: Tengo la respuesta

[SHK setRootViewController:self.navigationController]; 

necesita ser:

[SHK setRootViewController:self]; 

El problema fue que necesitaba un UIViewController, mientras pasaba un UINavigationViewController ...

Cuestiones relacionadas