我在应用程序委托中初始化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是我的根视图,我可以在其上面添加一个视图吗?或者我只能向它的一个子视图控制器(左抽屉、中央视图控制器或右抽屉)添加视图?
谢谢!
发布于 2014-07-29 01:50:30
ProgressHUD茧足类的来源提供了一个关于如何做这件事的提示。基本上,它将进度视图添加到窗口本身。
- (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就在屏幕中央,一切都在上面,就好像它完全不了解孩子的视图一样。
https://stackoverflow.com/questions/25006272
复制相似问题