我正在我的app委托中初始化MMDrawerController,如下所示:
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];
然后我将我的根视图控制器设置为MMDrawerController,如下所示:
[self.window setRootViewController:self.drawerController];
我希望能够在一个视图中覆盖UIActivityIndicator
在MMDrawerController内部所有内容的顶部,以便我可以采用全局方式在某些操作完成时使UI不可用。
如果MMDrawerController是我的根视图,我可以在它上面添加一个视图吗?或者我只能将视图添加到其中一个子视图控制器(左抽屉,中央视图控制器或右抽屉)?
谢谢!
答案 0 :(得分:1)
ProgressHUD cocoapod来源提供了如何进行此IMO的提示。基本上,它将进度视图添加到窗口本身。
- (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];
}
//...
}
我的左抽屉打开时我尝试显示ProgressHUD,因此它显示了左抽屉视图的一部分和中心视图的一部分。果然,HUD位于屏幕中间的所有内容之上,好像它完全不知道孩子们的观点。