UIButton inside UIScrollView, inside UIScrollview

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-14 02:25:22

问题


Controller A's view contains a UIScrollview which contains a UIButton. The content scrolls vertically and the button works fine.

Controller B's view contains a UIScrollview for paging left and right.

When I place my Controller A view inside the scroll view of Controller B's the UIButton stops working.

I can't 'de-nest' the scrollviews because they are managed by independent controllers - and paging is only required under certain circumstances.

Why does Controller B stop the button from working?


回答1:


From the UIViewController docs:

Note: You should not use view controllers to manage views that fill only a part of their window—that is, only part of the area defined by the application content rectangle. If you want to have an interface composed of several smaller views, embed them all in a single root view and manage that view with your view controller.

The OS only bothers to send events to a single UIViewController, whichever one it thinks is active and filling the window. Only that one view controller is sure to get events including rotation method calls and memory warnings.



来源:https://stackoverflow.com/questions/3167305/uibutton-inside-uiscrollview-inside-uiscrollview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!