tags:

views:

83

answers:

1

Hi all,

this is my first ever question so apologies if it's not descriptive enough.

I currently have an object that can be moved along an x axis with dragging. I need to limit it's movement to half of the screen.

Can anyone help

A: 

Well that is simple. Assuming we are talking about moving a UIView:

// Only move the object if its right bounding box position is
// in the first half of the screen

if ((someObjectView.frame.origin.x + someObjectView.frame.size.width) < 
        (containingView.bounds.size.width / 2.0) {
    // Move the object
}

You fill in the blanks :-)

St3fan
thanks St3fan, it's a UIImageView. is it called a bounding box ? I think that's where I may have gone wrong !!
Ross
The correct term in iPhone land is `frame`: the `frame` is the position of a view, expressed in coordinates in its superview.
St3fan