我的AppDelegate中有一个UIActionSheet
,由:
- (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
的范围内无效,但应该是,对吧?毕竟,我可以毫无问题地在self.tabBarController.selectedSegmentIndex = N
中执行AnotherViewController
之类的操作。
我甚至尝试更改showActionSheet:
,以便最后一行是[sheet showFromView:self.window]
。当然我的_window
应该可以全球访问吗?
我显然缺少一些基本的东西,但我不确定它是什么。
答案 0 :(得分:0)
您确定AppDelegate符合UIActionSheetDelegate协议吗?