xcode - Add gestures and animation in Swift -



xcode - Add gestures and animation in Swift -

i making application inspired ios8 voice messages , trying add together 'gestures , animations(like slide left , cancel record,slide rightto upload voice record.)' doesn't work @ all.here code snippet below.

// swipe left , cancel allow swipeleftgesture = uiswipegesturerecognizer(target: self, action: "swipeleftcancel") swipeleftgesture.direction = uiswipegesturerecognizerdirection.left self.view.addgesturerecognizer(swipeleftgesture) // swipe right , upload allow swiperightgesture = uiswipegesturerecognizer(target: self, action: "swiperightupload") swiperightgesture.direction = uiswipegesturerecognizerdirection.right self.view.addgesturerecognizer(swiperightgesture) session.requestrecordpermission({(granted: bool)-> void in if granted { self.setuprecorder() } else { println("permission record not granted") } }) func swipeleftcancel(sender: uiswipegesturerecognizer) { // slide left , cancel } func swiperightupload(sender: uiswipegesturerecognizer) { // slide right , upload )

whole code(before adding uiswipegesturerecognizer) in here ー> https://github.com/chansuke/goforit

anyone give advice?

your action selectors should named swipeleftcancel: , swiperightupload::

let swipeleftgesture = uiswipegesturerecognizer(target: self, action: "swipeleftcancel:")

the colon @ end necessary because functions take argument sender. because in objective-c, method declared - (void)swipeleftcancel:(id)sender, , selector swipeleftcancel:. in swift makes lot less sense, it's have remember when utilize selectors.

xcode animation swift ios8 gesture

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -