Obj-C,为什么我的 UIActionSheet 取消按钮很难点击?

发布于 2024-11-01 21:46:35 字数 523 浏览 1 评论 0原文

我注意到在我的应用程序中,我的取消按钮很难点击,似乎点击区域不在中心。

我该如何解决这个问题?

这是我的代码...

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"" 
  delegate:dg 
  cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil
  otherButtonTitles: @"Help Pages", @"Tutorial", 
  @"Feedback / Questions ", @"Facebook Group", @"About", nil];

actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[actionSheet setTag:CommonUIActionSheetHelp];
[actionSheet showInView:vw];
[actionSheet release];

I've noticed in my app that my cancel button is hard to tap, it seem like the hit area is not in the center.

How do I fix this ?

Heres my code...

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"" 
  delegate:dg 
  cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil
  otherButtonTitles: @"Help Pages", @"Tutorial", 
  @"Feedback / Questions ", @"Facebook Group", @"About", nil];

actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[actionSheet setTag:CommonUIActionSheetHelp];
[actionSheet showInView:vw];
[actionSheet release];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

伤痕我心 2024-11-08 21:46:35

我认为你的问题出在 [actionSheet showInView:vw]; 上,也许你在应用程序中使用 tabBarController/toolBar(在底部),此时就会发生此错误。

您应该根据您的设计使用 showFromToolbarshowFromTabBar。如果您的设计不同,请注明。(如果那里没有 tabBar/toolBar)。

谢谢

I think your problem lies in the [actionSheet showInView:vw];, perhaps you are using tabBarController/toolBar in you application(at bottom), this error occurs at that time.

you should use either showFromToolbar or showFromTabBar as per your design. If your design is different then please mention it.(if no tabBar/toolBar there).

Thanks

梦旅人picnic 2024-11-08 21:46:35

同意拉文的回答,你可以尝试

[actionSheet showInView:[UIApplication sharedApplication].keyWindow];

一下,也有帮助

agree whit Ravin answer and you can try

[actionSheet showInView:[UIApplication sharedApplication].keyWindow];

it can help also

指尖微凉心微凉 2024-11-08 21:46:35

我在 iOS 8 中遇到类似的问题,使用带有 UIAlertControllerStyleActionSheet 样式的 UIAlertController

问题是操作表上的第一次点击被忽略。

事实证明,这与我的文本字段的键盘干扰触摸有关。

解决方法是先关闭键盘,然后显示操作表。

[textfield resignFirstResponder];
[self presentViewController:alert animated:YES completion:nil];

I have similar problem in iOS 8, using UIAlertController with style UIAlertControllerStyleActionSheet.

The problem is that the first tap on the action sheet is ignored.

Turned out it got to do with my text field's keyboard interfering with the touches.

The fix is to dismiss the keyboard first, then present the action sheet.

[textfield resignFirstResponder];
[self presentViewController:alert animated:YES completion:nil];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文