views:

72

answers:

1

i have a uibutton. im using two images for UIControlStateNormal and UIControlStateSelected. when i touch down the button it shows the UIControlStateSelected image for a split second. what is the reason?

A: 

Hey Allen,

I'm not sure i've got ur question correctly but try setting the image for UIControlStateHighlighted instead of UIControlStateSelected if you want the other image to be displayed as long as you keep the button pressed.

Reference: UIControl Documentiation says,

Note that the control can be in more than one state

In you case Selected and Highlighted. So UIControlStateNormal image is the default image used for highlighted state.

This is my best guess.

Good Luck,

Swapnil

lukya
thanks for your reply. i dont want to display image in highlighted state.eg: i have two images like edit and delete. when i press the button edit image changed to delete. so im using one button and two images for UIControlStateNormal and UIControlStateSelected. while in selected state i can see delete image. When i touch down the button it shows edit image in a split sec.
Allen
ok!! my bad.but if you are toggling between states (and hence button images) on touch down the change should look smooth.can you please clarify what you mean you say "it shows edit image in a split sec."? does it show the edit image FOR a split second and the delete image again or there is a delay?
lukya
yes you are right. it shows the edit image for a split second and the delete image again.in touch down event it shows edit image and touch end it retutn to delete image.
Allen
are you setting/toggling the selected property of button to true/false on touch down??
lukya
not in touch down im setting the selected property only in the touch end.
Allen
can you please edit your question and post some code so it'll be clear where you are setting the images and selected states
lukya