ios - UIButton is unclickable after change in container height -


an uibutton contained inside uiscrollview. have setup in xib. use nslayoutconstraint change height of scrollview. after click button, scrollview changes height, uibutton becomes unclickable.

here code:

- (ibaction)tagpressed:(uibutton *)sender {      if (self.height.constant == 200) {         self.height.constant = 88;     }else        self.height.constant = 200;      [self.view setneedsupdateconstraints];      [uiview animatewithduration:0.5f animations:^{         [self.view layoutifneeded];     }];      drect(_scrollview.frame)     drect(self.view.frame)     drect(sender.frame)     nslog(sender.selected ? @"selected" : @"not selected"); 

}

drect nslog frames. console out is:

2013-04-08 17:04:19.264 touchselectapp[93618:c07] cgrect ( 20.000000, -112.000000, 62.000000, 200.000000) 2013-04-08 17:04:19.266 touchselectapp[93618:c07] cgrect ( 0.000000, 300.000000, 320.000000, 88.000000) 2013-04-08 17:04:19.266 touchselectapp[93618:c07] cgrect ( 7.000000, 78.500000, 48.000000, 44.000000) 

output (lldb) po [[uiapp keywindow] recursivedescription] had add button create debugging stop. button care inside selectabletag.

$0 = 0x0887e0e0 <uiwindow: 0x7197a90; frame = (0 0; 320 568); autoresize = w+h; layer =    <uiwindowlayer: 0x7199620>>    | <uiview: 0x719ed20; frame = (0 20; 320 548); autoresize = w+h; layer = <calayer: 0x719edd0>>    |    | <uiroundedrectbutton: 0x719b9d0; frame = (51 464; 73 44); opaque = no; autoresize = tm+bm; layer = <calayer: 0x719baf0>>    |    |    | <uigrouptableviewcellbackground: 0x719c2a0; frame = (0 0; 73 44); userinteractionenabled = no; layer = <calayer: 0x719c370>>    |    |    | <uiimageview: 0x719da50; frame = (1 1; 71 43); opaque = no; userinteractionenabled = no; layer = <calayer: 0x719dd20>>    |    |    | <uibuttonlabel: 0x719d0f0; frame = (12 12; 49 19); text = 'button'; clipstobounds = yes; opaque = no; userinteractionenabled = no; layer = <calayer: 0x719d1e0>>    |    | <uiview: 0x71a1160; frame = (0 300; 320 88); autoresize = rm+bm; layer = <calayer: 0x71a11c0>>    |    |    | <selectabletag: 0x719fcc0; baseclass = uiscrollview; frame = (20 -112; 62 200); clipstobounds = yes; autoresize = w+h; gesturerecognizers = <nsarray: 0x71a04e0>; layer = <calayer: 0x719fef0>; contentoffset: {0, 0}>    |    |    |    | <uiimageview: 0x71a0c20; frame = (55 193; 7 7); alpha = 0; opaque = no; autoresize = tm; userinteractionenabled = no; layer = <calayer: 0x71a0cc0>>    |    |    |    | <uiimageview: 0x71a0dd0; frame = (55 62; 7 7); alpha = 0; opaque = no; autoresize = lm; userinteractionenabled = no; layer = <calayer: 0x71a0e70>>    |    |    |    | <uiroundedrectbutton: 0x719ddd0; frame = (-1 7; 64 44); opaque = no; layer = <calayer: 0x719b630>>    |    |    |    |    | <uigrouptableviewcellbackground: 0x719d630; frame = (0 0; 64 44); userinteractionenabled = no; layer = <calayer: 0x719b690>>    |    |    |    |    | <uiimageview: 0x719dea0; frame = (1 1; 62 43); opaque = no; userinteractionenabled = no; layer = <calayer: 0x719d990>>    |    |    |    |    | <uibuttonlabel: 0x71a1630; frame = (12 12; 40 19); text = 'test1'; clipstobounds = yes; opaque = no; userinteractionenabled = no; layer = <calayer: 0x71a1e50>> 

(lldb)

from the documentation of hittest:withevent: in uiview class reference:

points lie outside receiver’s bounds never reported hits, if lie within 1 of receiver’s subviews. can occur if current view’s clipstobounds property set no , affected subview extends beyond view’s bounds.

the parent of scroll view view address 0x71a1160. notice scroll view's frame.origin.y -112. top 112 points of scroll view outside of parent's bounds. part of scroll view never receive touches. test1 button entirely in part of scroll view.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -