xcode - Touch up inside button not working properly -


i working on ui game. on title screen have variety of buttons on screen. 1 button toggle button allowing sound muted. have selected image being mute image. , default image being full sound image. have connection view controller sound button. connection action type occurs when button touched inside. code button is:

@ibaction func soundbutton(sender: uibutton) {      sender.selected = sender.selected!  } 

when app first loaded, title screen shown. on screen, sound button displays sound on. can click , hold button , image doesn't change. when release, image changes. works how want to, displays mute image, when click , hold button again, enable sound. image changes touch button, not when release after touched did first time. not huge bug, still know why might happen. , in advanced.

its odd there's no function name. but.. tested in absence of other code, , works expect - image doesn't change until touch registered.

that said - there visual change when button pressed. doesn't have selected property though. it's part of set of images can define. uicontrolstate.highlighted

here's how tested: viewdidload:

thebutton.setimage(uiimage(named: "icon_dark"), forstate: uicontrolstate.selected) thebutton.setimage(uiimage(named: "icon_light"), forstate: uicontrolstate.normal) 

and action button (on touch inside):

@ibaction func tap(sender: anyobject) {     thebutton.selected = !thebutton.selected } 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -