ios - No method declared with Objective c selector 'scale' -


i'm following stanford lecture on ios development. want create pinch gesture can enlarge or reduce size of smiley face. here original code:

faceview.addgesturerecognizer(uipinchgesturerecognizer(target: faceview, action: "scale:")) 

however, xcode complained "no method declared objective c selector 'scale'".

i followed suggestion replace "scale:" selector("scale:") still display same error message.

i did bit of research online , found out swift 2.2, syntax selector has changed #selector(myclass.methodname), changed line of code

faceview.addgesturerecognizer(uipinchgesturerecognizer(target: faceview, action: #selector(faceview.scale))) 

this time, no error message displayed, when run project , tried enlarge or reduce smiley face in simulator, not change size @ all.

seems changed since last release.

you have been suggested use #selector(myclass.methodname) documentation correct syntax

in case of stanford lecture have class on view called faceview method called scale.

so myclass faceview , selector #selector(faceview.scale)

as final line faceview.addgesturerecognizer(uipinchgesturerecognizer(target: faceview, action: #selector(faceview.scale)))

hope helped ya, faced same problem ;)


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -