UIActionSheet 在 ScrollView 中的定位问题
我试图在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设您的
UIScrollView
包含在UIViewController
的view
中。然后,您应该在视图控制器的根视图内显示该
UIActionSheet
。Assuming your
UIScrollView
is contained in theview
of aUIViewController
.You should then display that
UIActionSheet
inside the root view of the view controller.您将其显示在滚动视图内,这是行不通的,因为您是对的,它显示在屏幕外。您不应该将其显示在滚动视图中,而是将滚动视图放在另一个视图中并在该视图中显示 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.