ios - Make UIAlertViewController action unclickable? -


i want make uialertaction unclickable. have uialertview pops when try download something. when download finishes, want uialertview's action go being unclickable clickable. when becomes clickable, means download has finished. here's have far:

@iboutlet var activityview: uiactivityindicatorview!  var alert = uialertcontroller(title: nil, message: "please wait...", preferredstyle: uialertcontrollerstyle.alert)  override func viewdidload(){     self.activityview = uiactivityindicatorview(activityindicatorstyle: uiactivityindicatorviewstyle.whitelarge)     self.activityview.center = cgpointmake(130.5, 65.5)     self.activityview.color = uicolor.blackcolor() }  @ibaction func importfiles(sender: anyobject){     self.alert.view.addsubview(activityview)     self.presentviewcontroller(alert, animated: true, completion: nil)     alert.addaction(uialertaction(title: "ok", style: uialertactionstyle.default, handler: nil))     //somehow here want make uialertaction unclickable.     self.activityview.startanimating() } 

everything works can't seem find way action clickable when animation has finished. tried adding action uialertviewcontroller , present uialertviewcontroller again when download finished error saying can't present when uialertviewcontroller active. appreciated. thanks!

generally recommend against using alertview placeholder such task. give idea take @ this:

lazy var alert: uialertcontroller = {     var alert = uialertcontroller(title: "please wait...", message: "please wait seconds...", preferredstyle: .alert)     alert.addaction(self.action)     return alert }() lazy var action: uialertaction = {     var action = uialertaction(title: "ok", style: .default, handler: nil)     action.enabled = false     return action }()  override func viewdidappear(animated: bool) {     super.viewdidappear(animated)      self.presentviewcontroller(alert, animated: true, completion: nil)      let delayinseconds = 3.0     let poptime = dispatch_time(dispatch_time_now, int64(delayinseconds * double(nsec_per_sec)))     dispatch_after(poptime, dispatch_get_main_queue()) { () -> void in         self.action.enabled = true     } } 

where delay part

let delayinseconds = 3.0 let poptime = dispatch_time(dispatch_time_now, int64(delayinseconds * double(nsec_per_sec))) dispatch_after(poptime, dispatch_get_main_queue()) { () -> void in     self.action.enabled = true } 

should replaced fetching logic.

good luck!


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -