我试图用UIButton调用Sharekit,但当我点击设备上运行的按钮时,什么也没发生。
这应该是我的视图控制器的.h 中的相关代码
#import "SHK.h"
#import "SHKFacebook.h"
@interface ViewController : UIViewController <CaptureManagerDelegate>
{
IBOutlet UIButton *upload;
}
@property (nonatomic, retain) IBOutlet UIButton *upload;
-(IBAction)buttonPressed:(id)sender;
在我看来,controller的.m(使用示例中的代码http://gazapps.com/wp/2011/07/17/basic-sharekit-customization)
@synthesize upload;
-(IBAction)buttonPressed:(id)sender {
SHKItem *item;
NSURL *url = [NSURL URLWithString:@"http://www.gazapps.com"];
item = [SHKItem URL:url title:@"Checkout this site"];
[SHKFacebook shareItem:item];
}
-(void)dealloc
{
[upload release];
}
除了尝试使用UIButton而不是UIBarButton之外,我还严格遵循了Sharekit的安装说明。在我的故事板中,我用CTRL键拖动到"第一响应者",并将我的按钮链接到按钮Pressed。我在xcode中没有收到任何警告或错误。但当我点击按钮时什么也没发生。
您的代码看起来不错。问题可能在nib文件中。再次检查您的连接。您是否正在对upload
(UIButton)属性执行其他操作?如果你只想触发一个IBAction
,你根本不需要那个出口。
您可以在buttonPressed
方法中放置一个断点,以查看连接是否设置正确。
您应该使用SHKActionSheet
SHKActionSheet *actionSheet = [EDShareActionSheet actionSheetForItem:item];
[actionSheet showFromToolbar:self.navigationController.toolbar];