Sunday, May 23, 2010

Buttons not responding.

In playing around with my new MathDrill GUI, I'm adding subviews that display data for choices.  I'm placing these in a view that has easy coordinates for my subview, however what I've found is that if the view I'm placing has buttons outside the space on the screen for the superview, that the buttons DO NOT RESPOND.   This is annoying.  

The convertRect and convertPoint routines are essential here.  Do your math in the most convenient space for you, then use some built in utility routines to convert it to coordinates within the space you are interested in.

I modified my placement of the display of a text to select buttons from:

[self.displayArea addSubview:choiceView];

CGRect newFrame=[self.view convertRect:currentProblemDisplay.view.frame fromView:self.displayArea ];
[self.view addSubview:currentProblemDisplay.view];

This way the view is displayed in the same location, but regardless of if it is in the bounds of the variable displayArea, it will still respond to inputs.

No comments:

Post a Comment