ios - Activity indicator acting slow inside PHPhotoLibrary.sharedPhotoLibrary().performChanges -
i'm deleting photo assets , want show activity indicator while assets being deleted , stop when assets have been deleted code acting slow, know wrong?
phphotolibrary.sharedphotolibrary().performchanges({ phassetchangerequest.deleteassets(enumeration) self.activityindicator.startanimating() uiapplication.sharedapplication().beginignoringinteractionevents() }, completionhandler: {success, error in if success { self.activityindicator.stopanimating() uiapplication.sharedapplication().endignoringinteractionevents() println("success") } else { self.activityindicator.stopanimating() uiapplication.sharedapplication().endignoringinteractionevents() println("error") } })
i solved myself, here's answer:
phphotolibrary.sharedphotolibrary().performchanges({ phassetchangerequest.deleteassets(enumeration) let delay = 1 * double(nsec_per_sec) let time = dispatch_time(dispatch_time_now, int64(delay)) dispatch_after(time, dispatch_get_main_queue()) { self.activityindicator.startanimating() } }, completionhandler: {success, error in uiapplication.sharedapplication().beginignoringinteractionevents() if success { println("good") dispatch_async(dispatch_get_main_queue()){ self.activityindicator.stopanimating() self.navigationcontroller?.poptorootviewcontrolleranimated(true) } uiapplication.sharedapplication().endignoringinteractionevents() } else { println("bad") dispatch_async(dispatch_get_main_queue()){ self.activityindicator.stopanimating() } uiapplication.sharedapplication().endignoringinteractionevents() } })
just needed add:
dispatch_async(dispatch_get_main_queue()){ self.activityindicator.stopanimating() }
Comments
Post a Comment