Search code examples
iphoneobjective-cibaction

Why do my IBActions not get called in pageControll?


I have a view with IBActions tied to UITextFields and UIButtons. They all work as intended unless I use that view inside of a pageControl. If I do that the UITextField IBActions don't work but the UIButton IBActions do work.


Solution

  • I assume that by "page control" you mean UIScrollView+UIPagecontrol.

    In this case, the problem you are facing is the "greediness" of UIScrollView when it comes to touches. A UIScrollView will swallows all the touches (like a touch black hole) and will not let other controls receive them.

    One way forward is (but I am not saying that it will be easy): subclassing UIScrollView and overriding:

    touchesBegan:withEvent:
    touchesMoved:withEvent:
    touchesEnded:withEvent:
    

    so that you can dispatch the touch to your controls after verifying that they belong to them.