Crazy button behavior...

I have a simple uibutton with an image on the selected state. When the button is selected the first time it works perfectly. The second time it is set to selected the image is distorted. What the heck is happening?!?!?!?


I would post pics but apparently that isn't an option.

Accepted Reply

FINALLY! I figured it out. So the button seemed to me to be behaving like text was being added on the second user selection, very odd. So to fix this I selected the state config to "Selected." Then under the "Selected Symbol Configuration" panel, I set the "Configuration = Point Size" "Point Size = 17" "Scale = Default" "Weight = Regular." Then it works exactly as expected. My assumption was the previous entries for those fields being "Unspecified" was messing something up. All works well now. Thanks for your help. Hopefully this helps someone experiencing this weird UI behavior.

Replies

Distorted ? Do you mean stretched horizontally or vertically ? If so, what is the size of the image ?


Could you tell more on the button properties as defined in Attributes inspector:

- is type Custom ? (that would be normal)

- image as Image or background ? (should be image)

- is the image stored in Assets.xcassets (should be)

- what is the view content mode ? May try to change to Aspect Fit

- any other information you find useful

It appears to smash drastically verticallly. The first press works perfect and the ones after are distorted. I've been developing iOS apps for a decade and never seen this before.


Button is Custom

It is an image with no content insets

It is in the assets

Tried every content mode

Image is square 50 x 50 px @ 1x


Behaves the same on device as simulator.

Does it happens only on one button with a specific image ?


Did you try changing the image ?


I would try also to test some attributes.

- select the image in the assets

- open its attributes inspector

- try to change render mode to default or template

- try to change sxales to single scale

FINALLY! I figured it out. So the button seemed to me to be behaving like text was being added on the second user selection, very odd. So to fix this I selected the state config to "Selected." Then under the "Selected Symbol Configuration" panel, I set the "Configuration = Point Size" "Point Size = 17" "Scale = Default" "Weight = Regular." Then it works exactly as expected. My assumption was the previous entries for those fields being "Unspecified" was messing something up. All works well now. Thanks for your help. Hopefully this helps someone experiencing this weird UI behavior.

Thanks for feedback.


But it was not an image ! Your post was a bit misleading, it seems.

It was the image getting distorted. That is the crazy part. There is no text, no background or anything. A square button with a square image that you drag out of the ui library. Those “Unspecified “ settings caused the image to distort. Even though those settings appear to be for text only.