0

So right now I am using auto layout and figured out that when I make a if statement about intersecting, auto layout automatically puts the images back into their starting place.

I have tried many intersecting statements for example:

if (CGRectIntersectsRect(Poop.frame, toilet.frame)) {

    }

and

if(distance < (Poop.bounds.size.width/2.0 + toilet.bounds.size.width/2.0)){

}

AutoLayout just doesn't seem to cooperate with intersections! Please help me.

1 Answers1

1

Do I correctly infer that you are using autolayout, but have programmatically changed the frame (whether that be the origin or center or size or whatever) of some view, but that it's moving back? If so, the issue isn't what's triggering the moving it back, but rather how you changed the frame in the first place.

When using autolayout, you generally should not change the frame of a view, but rather adjust the constraints that you have on that view and let that dictate the new position of the view. For example, see https://stackoverflow.com/a/14190042/1271826.

Community
  • 1
  • 1
Rob
  • 415,655
  • 72
  • 787
  • 1,044