Posting to Facebook from Sharekit

故事扮演 提交于 2019-12-11 16:49:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!