我在UIViewController中创建了UITabbar。然后我添加了一个UIActionSheet但是当动作表出现时,单击按钮“取消”的顶部时,它可以工作,但是当我点击“取消”的底部时,没有响应。我用这段代码添加了动作表:
actionSheetDelete = [[UIActionSheet alloc] initWithTitle:@"Do you want to continue?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete Item(s)" otherButtonTitles:nil];
actionSheetDelete.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[actionSheetDelete showInView:self.view];
[actionSheetDelete release];
当我点击操作表时,我总是在控制台中显示此警报:
Presenting action sheet clipped by its superview. Some controls might not respond to touches. On iPhone try -[UIActionSheet showFromTabBar:] or -[UIActionSheet showFromToolbar:] instead of -[UIActionSheet showInView:].
你有什么建议吗?提前致谢
答案 0 :(得分:2)
尝试:
[actionSheetDelete showFromTabBar:self.tabBarController.tabBar];
答案 1 :(得分:1)
您可以在UITabBarController的视图中显示它:
actionSheetDelete = [[UIActionSheet alloc] initWithTitle:@"Do you want to continue?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete Item(s)" otherButtonTitles:nil];
actionSheetDelete.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[actionSheetDelete showInView:self.tabBarController.view];
[actionSheetDelete release];
或者,更强大的版本可能是:
[actionSheetDelete showInView:[UIApplication sharedApplication].keyWindow];
答案 2 :(得分:0)
您正试图从视图本身显示操作表。考虑到视图中已经有UITabBarController,这是无法做到的。因此,您必须在显示时从标签栏进行设置。这将确保按钮未加载到选项卡栏的视图下方,并允许与选项卡栏关联的所有操作的可用性。
因此,您应该使用
[actionSheetDelete showFromTabBar:];
以便标签栏是操作表显示位置的初始位置 希望这有帮助!