正确的方法来解决showFromTabBar的顶级UITabBarController视图

Jul*_*anB 2 iphone uitabbarcontroller uiactionsheet

主应用程序委托有一个名为tabBarController的UITabBarController(NewsUKDelegate.m)

第一个选项卡加载一个UIViewController,它会添加一个UITableView(FirstViewController.m)

选择单元格时,UITableView加载子类UIViewController(StoryController.m)

然后我从Sharekit加载共享操作表

NSURL *url = [NSURL URLWithString:link];
SHKItem *item = [SHKItem URL:url title:storyTitle];
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
[actionSheet showFromTabBar:rootView];
[actionSheet showFromTabBar:[self view]];
Run Code Online (Sandbox Code Playgroud)

它起作用(ish)但是动作表从顶部加载似乎是错误的,但重要的是它抱怨了

incompatible Objective-C types 'struct UIView *', expected 'struct UITabBar *' 
when passing argument 1 of 'showFromTabBar:' from distinct Objective-C type
Run Code Online (Sandbox Code Playgroud)

我试过去玩弄

UIWindow *topWindow = [[UIApplication sharedApplication] keyWindow];

if (topWindow.windowLevel != UIWindowLevelNormal)
{
    NSArray *windows = [[UIApplication sharedApplication] windows];
    for(topWindow in windows)
    {
        if (topWindow.windowLevel == UIWindowLevelNormal)
            break;
    }
}

UIView *rootView = [[topWindow subviews] objectAtIndex:0];  
NSLog(@"Root view is: %@",rootView);

[actionSheet showFromTabBar:rootView];
    [actionSheet showFromTabBar:NewsUKDelegate.tabBarController];
    [actionSheet showFromTabBar:NewsUKDelegate.view];
Run Code Online (Sandbox Code Playgroud)

但我只是崩溃了,解决主应用程序代理工具栏的正确方法是什么

kar*_*rim 7

使用,

[actionSheet showFromTabBar:self.tabBarController.tabBar];
Run Code Online (Sandbox Code Playgroud)