从Sharekit发布到Facebook

时间:2012-11-17 14:22:06

标签: iphone ios facebook ios6 sharekit

我是sharekit的新手。我试图发布一个简单的文本:@“Hello”到Facebook,但面临着这样做的问题..它引导我进入登录页面。我登录然后关闭并返回主屏幕。但是当我检查我的时间表时,它没有被添加..

我的ViewController.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController{
    UIButton *btn;
    IBOutlet UIToolbar *toolbar;
}

@property (nonatomic,strong) UIButton *btn;
- (IBAction)btnShareClicked:(id)sender;

@end

我的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

我已经包含了MessageUI,Security,SystemConfiguration框架......需要一些指导..

1 个答案:

答案 0 :(得分:1)

首先您应该尝试检查您是否在应用程序中使用更新的ShareKit API。如果不是,那么从SHareKIt站点添加更新的那个。

Here is Link for The ShareKit Site

以下是代码看到,当你想要通过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`.

我希望它对你有所帮助。