swift - Function not called with selector action -


i'm trying handle tap gesture in external uiviewcontroller's class function never called. here code:

import scenekit import uikit  class scenemanager { private let assetfolder: string private let maincamera: scnnode private let view: scnview private let scene: scnscene  init(view: scnview, assetfolder: string, scenefile: string, maincameraname: string, backgroundcolor: uicolor) {     self.assetfolder = assetfolder     self.scene = scnscene(named: (self.assetfolder + "/scene/" + scenefile))!     self.maincamera = self.scene.rootnode.childnodewithname(maincameraname, recursively: true)!     self.view = view     self.view.backgroundcolor = backgroundcolor     self.view.allowscameracontrol = false     self.view.pointofview = self.maincamera     self.view.scene = self.scene      //problem below     let gesture = uitapgesturerecognizer(target: self, action: #selector(self.handletap(_:)))     self.view.addgesturerecognizer(gesture) }  @objc func handletap(sender: uitapgesturerecognizer) {     print("hello") } } 

here viewcontroller class : import uikit import quartzcore import scenekit

class viewcontroller: uiviewcontroller { override func viewdidload() {     super.viewdidload()     let view = self.view as! scnview     view.showsstatistics = true      _ = scenemanager(view: view, assetfolder: "art.scnassets", scenefile: "euro_copter.dae", maincameraname: "camera", backgroundcolor: uicolor.blackcolor()) } } 

if has idea. in advance.

try following code may help

let gesture = uitapgesturerecognizer(target: self, action: #selector(scenemanager.handletap(_:))) 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -