Using CGRectIntersectsRect with IBOutletCollection of an array of uiviews -
hello have 3 views part of iboutletcollection. in array called myarrayofviews. i'd able use cgrectintersectsrect determine when of these 3 views overlap far no luck. thought loop through array twice , run cgrectintersectsrect no luck. missing. in advance!
for (uiview *view1 in self.myarrayofviews) { nslog(@"view1 %@",view1); (uiview *view2 in self.myarrayofviews) { nslog(@"view2 %@",view2); if( cgrectintersectsrect(view1.frame, view2.frame)) { nslog(@"overlap!"); } } }
you figured out problem was. here's how add check 2 views not same:
for (uiview *view1 in self.myarrayofviews) { (uiview *view2 in self.myarrayofviews) { if (view1 != view2 && cgrectintersectsrect(view1.frame, view2.frame)) { nslog(@"overlap!"); } } }
Comments
Post a Comment