我是 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 框架...需要一些指导..
最佳答案
首先,您应该尝试检查您的应用程序中是否使用更新的 ShareKit
API。如果没有,则从 SHareKIt 站点添加更新的 API。
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`.
希望对您有帮助。
关于iphone - 从 Sharekit 发布到 Facebook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13431432/