ios - removeFromSuperview() not working -


i wanted blur background when touch id asked , once authorization successfull, viewcontroller needs visible.but not happening.the viewcontroller still blurred if authorization successfull.can me on how solve this?

import uikit import localauthentication class tabbarviewcontroller: uitabbarcontroller {  @iboutlet weak var notetabbar: uitabbar!  override func viewdidload() { super.viewdidload()     self.authenticateuser()     self.tabbar.hidden = false     self.view.addgesturerecognizer(self.revealviewcontroller().pangesturerecognizer())      let userdefaults = nsuserdefaults.standarduserdefaults()     userdefaults.setobject(false, forkey: "sendmodetoggle")     userdefaults.setobject("avenir-medium", forkey: "font")      userdefaults.setobject(13, forkey:"fontsize")             // additional setup after loading view. } override func didreceivememorywarning() {     super.didreceivememorywarning()     // dispose of resources can recreated. }   /* // mark: - navigation  // in storyboard-based application, want little preparation before navigation override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {     // new view controller using segue.destinationviewcontroller.     // pass selected object new view controller. } */  // mark: touch id authentication  func authenticateuser() {     let context = lacontext()     var error: nserror?     let reasonstring = "authentication needed access app! :)"      let blureffect = uiblureffect(style: .light)     let blurvisualeffectview = uivisualeffectview(effect: blureffect)     blurvisualeffectview.frame = view.bounds     self.view.addsubview(blurvisualeffectview)      if context.canevaluatepolicy(lapolicy.deviceownerauthenticationwithbiometrics, error: &error)     {          context.evaluatepolicy(lapolicy.deviceownerauthenticationwithbiometrics, localizedreason: reasonstring, reply: { (success, policyerror) -> void in              if success             {                 print("authentication successful! :) ")                 blurvisualeffectview.removefromsuperview()              }             else             {                 switch policyerror!.code                 {                 case laerror.systemcancel.rawvalue:                     print("authentication cancelled system.")                 /*case laerror.usercancel.rawvalue:                     print("authentication cancelled user.")                  */                    case laerror.userfallback.rawvalue:                     print("user selected enter password.")                     nsoperationqueue.mainqueue().addoperationwithblock({ () -> void in                         self.showpasswordalert()                         blurvisualeffectview.removefromsuperview()                      })                 default:                     print("authentication failed! :(")                     nsoperationqueue.mainqueue().addoperationwithblock({ () -> void in                         self.showpasswordalert()                         blurvisualeffectview.removefromsuperview()                      })                 }             }          })      }     else     {         print(error?.localizeddescription)         nsoperationqueue.mainqueue().addoperationwithblock({ () -> void in             self.showpasswordalert()         })     }   }  } 

since removing view in closure, not in main thread. try dispatch removing code main thread:

if success {     print("authentication successful! :) ")     dispatch_async(dispatch_get_main_queue()) {         blurvisualeffectview.removefromsuperview()     } } 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -