0

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

我的 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 框架......需要一些指导......

4

1 回答 1

1

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

这是 ShareKit 网站的链接

这是代码,请参阅,当您想通过 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`.

我希望它对你有帮助。

于 2012-11-17T14:34:33.917 回答