I am initializing MMDrawerController in my app delegate like this:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
UIViewController *menu = (UIViewController *)[storyboard instantiateViewControllerWithIdentifier:@"menu"];
UINavigationController *center = (UINavigationController *)[storyboard instantiateViewControllerWithIdentifier:@"center"];
self.drawerController = [[MMDrawerController alloc]
initWithCenterViewController:center
leftDrawerViewController:menu
rightDrawerViewController:nil];
I then set my root view controller to be the MMDrawerController like this:
[self.window setRootViewController:self.drawerController];
I want to be able to overlay a UIActivityIndicator
inside a view over the top of all that's going on inside the MMDrawerController so that I can have a global way of making the UI unavailable while certain operations complete.
If MMDrawerController is my root view, can I add a view on top of it? Or can I only add views to one of its child view controllers (left drawer, center view controller, or right drawer)?
Thanks!
The ProgressHUD cocoapod source offers a hint as to how to do this IMO. Basically, it adds the progress view to the window itself.
- (id)init
{
self = [super initWithFrame:[[UIScreen mainScreen] bounds]];
id<UIApplicationDelegate> delegate = [[UIApplication sharedApplication] delegate];
if ([delegate respondsToSelector:@selector(window)])
window = [delegate performSelector:@selector(window)];
else window = [[UIApplication sharedApplication] keyWindow];
//...
- (void)hudCreate //called as part of the [ProgressHUD show] method
{
// ...
if (hud == nil)
{
hud = [[UIToolbar alloc] initWithFrame:CGRectZero];
hud.translucent = YES;
hud.backgroundColor = HUD_BACKGROUND_COLOR;
hud.layer.cornerRadius = 10;
hud.layer.masksToBounds = YES;
}
//...
if (hud.superview == nil)
{
if (interaction == NO)
{
CGRect frame = CGRectMake(window.frame.origin.x, window.frame.origin.y, window.frame.size.width, window.frame.size.height);
background = [[UIView alloc] initWithFrame:frame];
background.backgroundColor = [UIColor clearColor];
[window addSubview:background];
[background addSubview:hud];
}
else [window addSubview:hud];
}
//...
}
I tried showing the ProgressHUD while my left drawer was open, so it showed part of the left drawer view and part of the center view. Sure enough, the HUD was on top of everything, right in the middle of the screen, as if it was completely ignorant of the child views.