I am trying to use the MBProgressHUD
within an application. I am getting an error at the point the HUD is added to the view.
This is the code that adds the progress bar to the view.
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.view.window addSubview:HUD];
// Set determinate mode
HUD.mode = MBProgressHUDModeAnnularDeterminate;
HUD.labelText = @"Loading";
// myProgressTask uses the HUD instance to update progress
[HUD showWhileExecuting:@selector(processFieldEntries) onTarget:self withObject:nil animated:YES];
The application errors with:
*** Assertion failure in -[MBProgressHUD initWithView:], /Users/.../MBProgressHUD/MBProgressHUD.m:190
Also
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'View must not be nil.'
And
Crash: View must not be nil.
Does anyone know what the Assertion failure is for and how to resolve. The MBProgressHUD.m file is included in the Compile Sources under the Build Phases tab and header included in the file. The progress is being added to a process for processing field validation.
Hi here is a quick tip on the HUD display.
first, not trying to be flip here, but make sure that if you are initializing the HUD for a navigation controller, that you have one - or anything else for that matter. Note, the higher you stick the HUD in your view, the more interaction that will get disabled and covered by the HUD overlay (which is a good thing usually).
so for example if your in a basic view controller, or a modal, etc. do something like this:
HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD];
note that you are adding it to the same view you initialized it with.
also note you can stuff it in other views as well like: self.navigationcontroller.view, self.splitviewcontroller.view or my favorite: self.splitviewcontroller.view.superview (to cover and disable both sides of the view).
I think your issue will resolve itself if you follow init example with the correct view for your app.
be well.