Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ios-如何从操作按钮调用ShareKit共享_Ios_Objective C_Ios5_Ios6_Sharekit - Fatal编程技术网

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

ios-如何从操作按钮调用ShareKit共享,ios,objective-c,ios5,ios6,sharekit,Ios,Objective C,Ios5,Ios6,Sharekit,我是从这个设置ShareKit的示例开始工作的: 他们的例子是: - (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 Aweso

我是从这个设置ShareKit的示例开始工作的:

他们的例子是:

- (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。如果是这样的话,这应该可以解决问题

在you.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];

在没有看到全部代码的情况下,听起来好像没有UINavigationController,只有UIViewController。如果是这样的话,这应该可以解决问题

在you.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];