iphone - Intrinsic size not updating when changing UIButton state -
i have uiview contains uibutton. uibutton has 2 titles set uicontrolstatenormal ("follow") , uicontrolstateselected ("following") states. using auto layout on uibutton , has constraint distance top of superview , distance left side of superview. i've used "size fit content" on it.
when set button in selected state code, title changes correctly intrinsic width of uibutton doesn't change when changing "follow" "following" text gets ellipsized.
self.selected = self.following;
when approach problem differently , change text uicontrolstatenormal when hits button, button changes size correctly.
nsstring *title = (self.following) ? @"following" : @"follow" [self settitle:title forstate:uicontrolstatenormal];
is bug in uikit? expect button change intrinsic size correctly reflect new size of text when state changes because there other things change besides text 2 button states.
like david caunt pointed out in comment, calling invalidateintrinsiccontentsize
cause autolayout resize button fit it's new content.
self.selected = self.following; [self invalidateintrinsiccontentsize];
ps. david, if want post commant answer remove mine.
Comments
Post a Comment