簡體   English   中英

iOS-如何從操作按鈕調用ShareKit共享

[英]ios - how to call the ShareKit share from an action button

我正在通過設置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];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM