Overlapping views and touch event regions are inconsistent

I have placed 2 views (table views) within a view container that are partially overlapped, on purpose. View A overlaps about 50% of View B.


User uploaded file

If I move View B so they no longer overlap:


User uploaded file User uploaded file


The screenshot on the left shows the 2 views after the move. The screen on the right shows a blue region which represents where the original view was and where the touch events for viewB are.


The previously overlapped region within View A does not respond to touch events, that is, ~50% does not, i.e. the overlapped portion you see in the above screen shot.. Only the region that wasn't orginally overlapped does. In addition, within View B, the portion that is now occupying new space within the superview, does not respond to touch events, only the portion of the view that happens to occupy the old region.


The code is simple that I'm using to move the view:


UIView* viewA = [self.childViewControllers[0] view];

UIView* viewB = [self.childViewControllers.lastObjectview];

CGRect rect = main.frame;

rect.origin.x += viewB.frame.size.width;


[UIViewanimateWithDuration:0.2animations:^{

viewB.frame = rect;

}];


Visually, the view moves but the touch region doesn't.


I used the new storyboard "Container View" mechanism within iOS 6 to initially place the views.


I have no idea why this is happening. Any ideas?


Thanks.

iMac, Mac OS X (10.7.2), 27" Intel Core I5 - 4GB ram

Posted on Jan 9, 2013 11:47 AM

Reply
2 replies

Jan 14, 2013 4:12 PM in response to zinc1oxide1

As it turns out, when xCode adds the "Container View" within my storyboard, it embeds my view within a parent view. So I need to do the following: (Note: code slightly simplified from above)

UIView* viewB =[[self.childViewControllers.lastObject view]superview];

CGRect rect = viewB.frame;

rect.origin.x +=200;

[UIView animateWithDuration:0.2 animations:^{ viewB.frame = rect;}];

Because the container embeds my view within it's own view, I need to get the superview and work with that.

If I were to do all of this programatically, that is, add the container and view myself using the container API, my original code would work.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Overlapping views and touch event regions are inconsistent

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.