ios - 如何从操作按钮调用 ShareKit 共享

标签 ios objective-c ios5 ios6 sharekit

我正在使用这个设置 ShareKit 的示例:http://getsharekit.com/install/

他们的例子是这样的:

- (void)myButtonHandlerAction
{
    // Create the item to share (in this example, a url)
    NSURL *url = [NSURL URLWithString:@"http://getsharekit.com"];
    SHKItem *item = [SHKItem URL:url title:@"ShareKit is Awesome!"];

    // Get the ShareKit action sheet
    SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];

    // Display the action sheet
    [actionSheet showFromToolbar:navigationController.toolbar];
}

但是最后一行给我一个语法错误:

Use of undeclared identifier 'navigationController'

另外,我的函数是这样定义的,因为我希望在用户按下共享按钮后调用共享库:

- (IBAction)share:(id)sender

谁知道我为什么会收到此错误以及在我的案例中调用共享功能的正确方法是什么?

谢谢!

最佳答案

没有看到你的整个代码,听起来你没有 UINavigationController,只有 UIViewController。如果是这样的话,这应该可以解决问题。

在你的 .h 文件中

@property (nonatomic, strong) IBOutlet UIWindow *window;
@property (nonatomic, strong) UINavigationController *NVC;

在你的 .m 文件中

UIViewController *theViewController = [[TheViewController alloc]initWithNibName:@"TheViewController" bundle:nil];

self.NVC = [[UINavigationController alloc] initWithRootViewController:theViewController];

[[self window] setRootViewController:NVC];

[self.window makeKeyAndVisible];

关于ios - 如何从操作按钮调用 ShareKit 共享,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15963110/

相关文章:

ios - 你如何创建一个对象的 NSMutableArray,它不会增加添加到它的每个对象的保留计数?

iOS 对 touchesbegan 的持续时间有限制吗?

iphone - iOS 5 中 UILabel 的多色

ios - 用一些数据初始化一个 UIView 服装类?

objective-c - 在 tvOS 下有条件编译的最佳方法是什么

objective-c - 由 NSMutableArray 支持的 NSArray @property

objective-c - UIImageView setImage 不起作用

objective-c - 更改 UIStepper 的外观

objective-c - requestAccessToEntity iOS6-向后兼容-EKEventStore

ios - 在 iOS 4.3 中将 YpCbCr iPhone 4 相机帧渲染为 OpenGL ES 2.0 纹理