ios - Keypad and alert view don't disappear when tapping outside in Swift 4? -


i new swift. creating app when user comes app, shows rating app alert box , when user wants input number. @ same time, keypad , alert box comes on view , there no way disappear screen. please, me solve problem, when 2 dialogs up, let user disappear in order respond either keypad or rating alert. here code below. help.

here image causing not dismiss: http://imgur.com/a/7hs9y

mainviewcontroller

 override func touchesbegan(_ touches: set<uitouch>, event: uievent?) {     self.view.endediting(true) } 

appdelegate rating app alert.

      func application(_ application: uiapplication, didfinishlaunchingwithoptions launchoptions: [uiapplicationlaunchoptionskey: any]?) -> bool {         // override point customization after application launch.          let shortesttime: uint32 = 1         let longesttime: uint32 = 10         guard let timeinterval = timeinterval(exactly: arc4random_uniform(longesttime - shortesttime) + shortesttime) else { return true }          timer.scheduledtimer(timeinterval: timeinterval, target: self, selector: #selector(appdelegate.requestreview), userinfo: nil, repeats: false)          return true       }  @objc func requestreview() {     if #available(ios 10.3, *) {         skstorereviewcontroller.requestreview()     } else {         // fallback on earlier versions     } } 

in swift 3, try code in project , edit wish

    override func viewdidload() {             super.viewdidload()      // *** hide keyboard when tapping outside ***             let tapgesture = uitapgesturerecognizer(target: self, action: #selector(tapgesturehandler))             view.addgesturerecognizer(tapgesture)         }      func tapgesturehandler() {         view.endediting(true)     } 

i hope it's work you,


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -