调用UIActionSheet被放置在AppDelegate中从AppDelegate中
问题描述:
外我有我的一个的AppDelegate UIActionSheet
被名为:调用UIActionSheet被放置在AppDelegate中从AppDelegate中
- (void)showActionSheet {
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Call Lilly" otherButtonTitles:@"Email IMCLONE Trials", @"Email EmergingMed", nil];
[sheet showFromTabBar:self.tabBarController.tabBar];
}
我需要从AnotherViewController
调用它。在控制器中我有:
[(LYAppDelegate *)[[UIApplication sharedApplication] delegate] showActionSheet];
...并且这不起作用。我得到的错误:
[3990:207] *** Assertion failure in -[UIActionSheet _presentSheetFromView:above:], /SourceCache/UIKit_Sim/UIKit-1912.3/UIActionSheet.m:1747
我假设的问题是,参考self.tabBarController.tabBar
是不是在AnotherViewController
范围内有效,但它应该是吧?毕竟,我可以在AnotherViewController
之内做任何事情,例如self.tabBarController.selectedSegmentIndex = N
。
我甚至试过改变showActionSheet:
以便最后一行是[sheet showFromView:self.window]
。当然我的_window
应该可以全球访问?
我很明显错过了一些基本的东西,但我不确定它是什么。
答
你确定你的AppDelegate符合UIActionSheetDelegate协议吗?
是的,我已经通过在'LYAppDelegate'中调用'showActionSheet'来测试它。 – 2012-03-01 16:38:02
你有没有确定你是从主线程调用它? – deleterOfWorlds 2012-03-01 16:40:19
我会不得不做任何不寻常的事情来从主线程调用它?我使用'didSelectRowAtIndexPath'从'AnotherViewController'调用它。没有Web服务调用,没有任何异步进行。我应该做些什么来确保它是从主线程调用的? – 2012-03-01 16:44:40