3

我在 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:].

你有什么建议吗?提前致谢

4

3 回答 3

2

尝试:

[actionSheetDelete showFromTabBar:self.tabBarController.tabBar];
于 2013-08-12T02:10:40.833 回答
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];
于 2013-08-12T02:10:26.100 回答
0

您正在尝试从视图本身显示操作表。考虑到您已经在视图中拥有了 UITabBarController,这无法完成。因此,您必须在显示时从选项卡栏中进行设置。这将确保按钮不会加载到选项卡栏的视图下方,并允许与选项卡栏关联的所有操作可用。

因此,您应该使用

[actionSheetDelete showFromTabBar:];

以便标签栏是显示​​操作表的初始位置希望这会有所帮助!

于 2013-08-12T03:48:51.150 回答