问题
I am using UIPageControl
as indicator between different page (view controllers) of my application. In each of the view controllers, I need to have a different button on the left corner on the UIPageControl. If I place a UIButton
at that position on each of the view controllers, I see it on the UIPageControl
but the buttons do not respond to the touch event. Is there something I am missing? Or is there an alternative to do this? Thanks.
回答1:
I guess the page control and the view controller view are both subviews of the same view. In this case, the button is drawn outside of the view controllers view bounds. This is allowed by default, but it does have the side effect that the button can't be tapped on as the superview doesn't handle the touch.
You should have the buttons on the page control owned by the 'super' view controller (the controller that owns the root view containing the page control and the child view controllers). Then, when a button is tapped it should tell the child view controller about it so that it can take the appropriate action.
来源:https://stackoverflow.com/questions/21355809/ios-uibutton-on-uipagecontrol-not-working