问题
I am newbie to sharekit. I am trying to post a simple text: @"Hello" to Facebook, but facing problems in doing so.. It leads me to the login page. I login and then it closes and comes back to the main screen. But when i check my timeline, it is not added..
My ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController{
UIButton *btn;
IBOutlet UIToolbar *toolbar;
}
@property (nonatomic,strong) UIButton *btn;
- (IBAction)btnShareClicked:(id)sender;
@end
My ViewController.m
#import "ViewController.h"
#import "SHK.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize btn;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
{
self.toolbarItems = [NSArray arrayWithObjects:
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(btnShareClicked:)] ,
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
nil
];
}
return self;
}
- (IBAction)btnShareClicked:(id)sender {
NSString *text = @"Hello";
SHKItem *item = [SHKItem text:text];
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
// For Toolbar
//[actionSheet showFromToolbar:toolbar];
[actionSheet showInView:self.view];
}
@end
I have included the MessageUI,Security,SystemConfiguration frameworks... Need some guidance on this..
回答1:
First You should try to Check whether you are using the updated ShareKit
API in Your Application.if Not then Add That Updated One from The SHareKIt Sites.
Here is Link for The ShareKit Site
Here Is the Code See,Called WhenEVer You want to share text Over the Facebook.
-(void)shareOnFacebook{
SHKItem * ietm1= [[SHKItem alloc] init];
[ietm1 setText:@"Hello"];
SHKFacebook *shkFacebook = [[SHKFacebook alloc] init]
[shkFacebook setSHKItem:item];
}
//see whether you have these Classes in your `ShareKit`.
I hope it may Helpful to you.
来源:https://stackoverflow.com/questions/13431432/posting-to-facebook-from-sharekit