I ran into your problem and worked out a solution, perhaps not the most beautiful, but it solves the problem. There is a delagate called SHKSharerDelegate, which can be used with supporters of this purpura, so if you call accessors directly from your code (there is no action sheet), you should do something like this:
NSString* mySharerClassName = @"SHKFacebook"; SHKSharer* classItem = (SHKSharer*)[[NSClassFromString(mySharerClassName) alloc] init]; Class sharerClass = [classItem class]; if ( [sharerClass canShare] ){ [classItem performSelector: @selector(setItem:) withObject: item];
If you need to use ActionSheet, it gets a little more complicated, mainly because there is no support for it, just go to the ActionSheet header file (ShareKit / UI / SHKActionSheet.h) and add the delegate property:
@property (nonatomic, retain) id sharerDelegate;
Please note that this is not an id<SHKSharerDelegate> , try to do this and you will experience a lot of pain . That’s why I said that it’s not the most beautiful. After you have added and synthesized the property, find this method:
- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated
And where is he talking
id sharer = [sharers objectAtIndex:buttonIndex]; [NSClassFromString(sharer) performSelector:@selector(shareItem:) withObject:item];
Change it to
id sharer = [sharers objectAtIndex:buttonIndex]; if ( sharerDelegate == nil ){ [NSClassFromString(sharer) performSelector:@selector(shareItem:) withObject:item]; }else{ SHKSharer* classItem = [[NSClassFromString(sharer) alloc] init]; [classItem performSelector: @selector(setItem:) withObject: item]; [classItem performSelector: @selector(setShareDelegate:) withObject: sharerDelegate]; [classItem performSelector: @selector(send)]; }
If you are more interested in this, I will try to make a blog entry soon and edit the answer to link to it. Hope I can still help someone!
source share