在Ipad滚动视图中使用bringSubviewToFront
在我的 iPad 应用程序中,我有一个拆分视图,其中详细视图是滚动视图...... 我有 3 个滚动视图子视图,它们是表格视图...... 执行操作时,如何使用 - (void)bringSubviewToFront:(UIView *)view
将滚动视图的子视图之一带到前面? (因为视图按照添加顺序“堆叠”,最后一个位于顶部)。我应该在子视图中还是在detailViewController中编写代码以及如何调用它?
In my Ipad app, I have a split view in which the detail view is a scroll view...
I have 3 subviews to the scrollview which are tableviews...
How do I use - (void)bringSubviewToFront:(UIView *)view
to bring one of the subviews of the scrollview to the front when an action is performed? (since Views are "stacked" in the order they're added with the last one on top). Should I write the code in the subview or in the detailViewController and how do I call it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在控制器中编写代码。
控制器应该可以通过 IBOutlet 属性访问表视图。或者,如果您没有使用笔尖设置它们,则控制器应该是创建它们的人。
例如,如果按钮点击负责显示特定的表格视图,则按钮的操作处理程序方法就是您调用
bringSubviewToFront:
方法的位置。但是:听起来您有三个彼此重叠的表视图,并使用
bringSubviewToFront:
来显示当前的表视图,并且它们都位于 UIScrollView 内。每个 UITableView 都包含一个 UIScrollView。不要将滚动视图放在滚动视图中,它们会争夺跟踪触摸,事情会变得很奇怪。只需将三个表视图放入一个普通的 UIView 中即可。
您应该考虑隐藏非活动视图(调用
setHidden:
),而不是bringSubviewToFront:。这样,隐藏的视图就不会被视为响应者链的一部分(不会收到发送的事件)。You write the code in the controller.
The controller should have access to the table views through
IBOutlet
properties. Or, if you didn't set them up using a nib, the controller should have been the one to create them.If a button tap, for example, is responsible for showing a particular table view, the button's action handler method is where you call the
bringSubviewToFront:
method.HOWEVER: It sounds like you have three table views on top of each other and are using
bringSubviewToFront:
to show the current one, and they are all inside a UIScrollView.Each UITableView contains a UIScrollView. Don't put a scrollview inside a scrollview, they will fight over tracking touches and things will get weird. Just put the three table views inside a plain UIView.
Instead of bringSubviewToFront:, you ought to consider hiding the inactive views (call
setHidden:
). That way, the hidden views won't be considered part of the responder chain (won't get sent events).