的正确方法是什么
主应用程序委派有一个名为tabBarController(NewsUKDelegate.m)的UITabBarController
第一个选项卡加载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]];
它工作(ish),但操作表从顶部加载,这似乎是错误的,但重要的是它抱怨
incompatible Objective-C types 'struct UIView *', expected 'struct UITabBar *'
when passing argument 1 of 'showFromTabBar:' from distinct Objective-C type
我试着和鬼混
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];
但我只是遇到了崩溃,解决主应用程序的代理工具栏
使用,
[actionSheet showFromTabBar:self.tabBarController.tabBar];
((myAppDelegate *)[UIApplication sharedApplication]).delegate.tabBar