Reputation: 9471
Something strange is happening. Basically, I am trying to recreate the messaging app. So when I am trying to get the Send button to change from Grey to blue when the user has typed in at least 1 character.
The problem comes when I am trying to change titleLabel, the button will disappear. Later I found out it reverts back to the old position (when the keyboard it not shown).
Why does it do this? If I do not modify the titleLabel everything works as usual. However, if I do, the UIButton goes back to the original location. If you need any sample code let me know, but I am not sure what to put on here as it's just [self.button.titleLabel setTextColor: [UIColor blueColor];
in the UITextViewdidChange
but it's acting strange.
Thanks! Alan
Upvotes: 1
Views: 1044
Reputation: 3496
Well as mentioned here by others, you might be "fighting" with auto-layout. You do not have to ditch auto-layout, you could just bind the NSLayoutConstraint
to an IBOutlet
property, and update the constraint. If you do not have a constraint, then one is created automatically for you - you should create one manually and attach it. If it is created in code, the find it by code and save a reference to it.
You could also go back to the simpler AutoResizing, which was there before auto-layout (and is not deprecated, yet).
Upvotes: 1
Reputation: 364
You might be fighting against auto-layout. I saw similar behavior, and someone answered my question here: Why does UIButton resize when I access titleLabel property?. Basically, I was suggested to forego auto-layout completely or only use auto-layout (never set frames programmatically).
Upvotes: 1