Results 1 to 3 of 3

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: Creating Custom Controls

  1. #1
    What's Jailbreak?
    Join Date
    Feb 2008
    Location
    Basel, Switzerland, Europe
    Posts
    8
    Thanks
    0
    Thanked 1 Time in 1 Post
    Default Creating Custom Controls
    Hi,

    For my application I need a color picker control. I subclassed UIControl, and it works fine:



    But then, I placed the color picker in a cell of a table, and now seemingly it doesn't call the touchesMoved:withEvent method. Because of that I cant "slide" the slider along the color bar. Funnily enough the touchesBegan:withEvent seems to be called, because when I tap the color bar, the slider jumps to the tapped place.
    Could somebody help mo out, please? How do I have to handle moving touches like the UISlider control does?

    Thanks,
    DrummerB

    EDIT: I've found a temporary solution. If I set the UITableView's scrollEnabled property to NO, then it works. But I wonder why the UISlider works even if scrolling is enabled...
    Last edited by DrummerB; 06-07-2008 at 09:08 AM.

  2. #2
    See a better solution where:
    Apple - Support - Discussions - [iPhone SDK] Events Filtered: UIControl ...


    First let me explain what happens:
    The UITableView extends from UIScrollView. UIScrollView intercepts all the events to make the decision if it is a scroll or not, if not it passes the event to the subviews. (Except when you have a UIslider)

    The solution is to extend UITableView and override this method:
    -(UIView *)hitTestCGPoint)point withEventUIEvent *)event {

    UIView *v = self viewWithTag:999; //999 is the tag of your subview, that you want to capture events
    CGPoint convertedPoint = self convertPointoint toView:v;

    // If the touch is inside the view, let the view handle it
    if (v pointInside:convertedPoint withEvent:event) {
    return v;
    } else {
    return super hitTestoint withEvent:event;
    }
    }
    When you Extend UISlider the hitTest returns the sliderview on a touch event but not when you extend UIControl. That I can not explain.

    Overriding the hitTest you can test if the point argument is inside in your view (converting to its coordinates) and Return it the view like what happens in a UISlider.

    If someone know why the UISlider is an exception in this hitTest method, please tell us.

    Hope this helps you people, trying to capture touches in a UITableView or UIScrollView without the interference of the scrool detection.

    Best regards, Joćo
    http://www.nanoappz.com/
    Last edited by askmehow; 12-07-2008 at 07:10 PM. Reason: formating text

  3. #3
    Quote Originally Posted by askmehow View Post
    See a better solution where:
    Apple - Support - Discussions - [iPhone SDK] Events Filtered: UIControl ...


    First let me explain what happens:
    The UITableView extends from UIScrollView. UIScrollView intercepts all the events to make the decision if it is a scroll or not, if not it passes the event to the subviews. (Except when you have a UIslider)

    The solution is to extend UITableView and override this method:

    When you Extend UISlider the hitTest returns the sliderview on a touch event but not when you extend UIControl. That I can not explain.

    Overriding the hitTest you can test if the point argument is inside in your view (converting to its coordinates) and Return it the view like what happens in a UISlider.

    If someone know why the UISlider is an exception in this hitTest method, please tell us.

    Hope this helps you people, trying to capture touches in a UITableView or UIScrollView without the interference of the scrool detection.

    Best regards, Joćo
    http://www.nanoappz.com/


    Can you please share your code i am having the same problem and not getting fixed...

    Appreciate your help.

    Thanks,

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •