开发者

Using bringSubviewToFront in Ipad scrollview

开发者 https://www.devze.com 2023-02-26 18:34 出处:网络
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...

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 d开发者_如何学Pythono 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?


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.

  1. 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.

  2. 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).

0

精彩评论

暂无评论...
验证码 换一张
取 消