liufengting / FTIndicator

A light wight UI package contains local notification, progress HUD, toast, with blur effect, elegant API and themes support.
MIT License
295 stars 63 forks source link

Indicator not dismissing #8

Open keithlee opened 7 years ago

keithlee commented 7 years ago

Issue happens when:

1) Load a viewcontroller, query something in the background (e.g. Parse query.findObjectsInBackground) 2) In query.findObjectsInBackground callback (dismiss Progress) 3) Indicator still there

Note: Only occurs on first time FTIndicator is loaded. Hacked around issue by callign showprogress and then dismissprogress in AppDelegate before any views can be loaded

Happens when loading a new view controller. I believe the indicator hasn't had time to load before calling my dismiss, which causes the issue. Showing and dismissing progress occurs on main thread

liufengting commented 7 years ago

I think maybe when query done callback, you should call dispatch_get_main_queue().

keithlee commented 7 years ago

I tried that, still didn't work. Confirmed that showing/dismissing is on main queue. Its something about the initial initialization of the FTIndicator thats having issues

liufengting commented 7 years ago

I tried the following methods, works fine. Just upload some code, try run the demo and click the + button on the up-left. Maybe let me see some of your code to help me understand more about this issue. Thanks.

}

keithlee commented 7 years ago

This is the code snippet where the problem is occurring. It only occurs the first time I see FTIndicator and only when I’m switching to or loading a new view controller. After that everything works fine. I can clear the indicator that won’t go away, by performing an action that shows the indicator again.

When I debug, the breakpoint hits dismissProgress callback before the indicator is actually shown.

private func fetchObjects(){ FTIndicator.showProgressWithmessage("") query.findObjectsInBackground { (objects: [PFObject]?, error: Error?) in FTIndicator.dismissProgress()

On Dec 7, 2016, at 6:51 PM, Liu Fengting notifications@github.com wrote:

I tried the following methods, works fine. Just upload some code, try run the demo and click the + button on the up-left. Maybe let me see some of your code to help me understand more about this issue. Thanks.

`

(void)viewDidLoad { [super viewDidLoad];

[FTProgressIndicator showProgressWithmessage:@"Something is happening..."];

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

for (NSInteger i = 0; i < 1000; i++) { NSLog(@"print out %ld",i); }

sleep(3);

dispatch_async(dispatch_get_main_queue(), ^{ [FTProgressIndicator dismiss]; }); });

}

`

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/liufengting/FTIndicator/issues/8#issuecomment-265639099, or mute the thread https://github.com/notifications/unsubscribe-auth/ABQm0UQFEcs-Npxy7DBvutlPMZqEp4kWks5rF3DJgaJpZM4LHWO9.

liufengting commented 7 years ago

Make sure it is dispatch_async. other than that, I can't find any other way to solves this for now.

keithlee commented 7 years ago

I tried dispatch_async but issue still occurs

On Dec 7, 2016, at 7:09 PM, Liu Fengting notifications@github.com wrote:

Make sure it is dispatch_async. other than that, I can find any other way to solves this.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/liufengting/FTIndicator/issues/8#issuecomment-265641526, or mute the thread https://github.com/notifications/unsubscribe-auth/ABQm0VUT-WXr8pngoWqWrT57ZmsAwTfSks5rF3UAgaJpZM4LHWO9.