I have an UIViewController
from which I am presenting a modal view.
[self presentViewController:modal animated:YES completion:nil];
It has two UIBarButtonItems
(named Cancel and Save). I am performing some action on Save button tap. I am displaying SVProgressHUD
Indicator on -saveButtonTapped
method.
- (IBAction)saveButtonTapped:(id)sender
{
NSLog(@"Modal Save Pressed.");
[SVProgressHUD showWithStatus:@"Loading..."];
// Some other code...
}
The problem is that the indicator is not displaying in front of my ModalView
. It starts animating but behind the ModalView
, not in front.
What is happening :
UIViewController ===> SVProgressHUD ===> ModalView
What I want :
UIViewController ===> ModalView ===> SVProgressHUD
I searched but didn't find any solution for that.
Why this is happening and how to solve this issue ?
Finally, I got to manage the issue using NSThread.
Actually, I was calling one method named -postForEditDispatch
from my -saveButtonTapped
method. I created one separate thread using -detachNewThreadSelector:toTarget:withObject:
and tried to call that method on that thread.
Sample Code :
- (IBAction)saveButtonTapped:(id)sender
{
NSLog(@"Modal Save Pressed.");
[SVProgressHUD showWithStatus:@"Loading..."];
// Some other code...
[NSThread detachNewThreadSelector:@selector(postForEditDispatch:) toTarget:self withObject:nil];
}