UIActionSheet 在 ScrollView 中的定位问题

发布于 2024-09-15 14:34:33 字数 811 浏览 4 评论 0原文

我试图在 scrollview 中触摸屏幕时显示 ActionSheet。操作表在第一页内弹出良好。但在后续页面上,屏幕变暗并且不显示任何内容,就好像实际按钮显示在屏幕外一样。我已经测试了 UIActionSheet 的不同框架定位,但它似乎不起作用。

self.view.frame.origin.x 似乎有正确的 ScrollView 位置。

UIActionSheet *actionSheet = [[UIActionSheet alloc] 
                                  initWithTitle:nil 
                                  delegate:self 
                                  cancelButtonTitle:@"Cancel"
                                  destructiveButtonTitle:nil 
                                  otherButtonTitles:@"Jump to First Page", @"Browse Pages",nil];

CGRect frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, 480.0f, 320.0f);  
[actionSheet setFrame:frame];
[actionSheet showInView:self.view];

I'm trying to display an ActionSheet when a screen is touched within scrollview. The action sheet pops fine within the first page. But on subsequent pages the screen becomes dark and doesn't displaying anything, as if actual button is displaying on the off screen. I have tested different frame positioning of UIActionSheet but it does not seem to work.

self.view.frame.origin.x seems to have correct ScrollView position.

UIActionSheet *actionSheet = [[UIActionSheet alloc] 
                                  initWithTitle:nil 
                                  delegate:self 
                                  cancelButtonTitle:@"Cancel"
                                  destructiveButtonTitle:nil 
                                  otherButtonTitles:@"Jump to First Page", @"Browse Pages",nil];

CGRect frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, 480.0f, 320.0f);  
[actionSheet setFrame:frame];
[actionSheet showInView:self.view];

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

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

发布评论

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

评论(2

涙—继续流 2024-09-22 14:34:33

假设您的 UIScrollView 包含在 UIViewControllerview 中。

然后,您应该在视图控制器的根视图内显示该UIActionSheet

Assuming your UIScrollView is contained in the view of a UIViewController.

You should then display that UIActionSheet inside the root view of the view controller.

看春风乍起 2024-09-22 14:34:33

您将其显示在滚动视图内,这是行不通的,因为您是对的,它显示在屏幕外。您不应该将其显示在滚动视图中,而是将滚动视图放在另一个视图中并在该视图中显示 ActionSheet。

You are displaying it inside the scrollview, which will not work, because you are right, it is displayed off screen. you shouldn't display it inside the scrollview, rather, put the Scrollview in another view and display the ActionSheet inside that view.

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