gpt4 book ai didi

ios - 在 MMDrawerController 之上放置一个 View

转载 作者:行者123 更新时间:2023-11-29 02:46:52 26 4
gpt4 key购买 nike

我正在我的应用委托(delegate)中初始化 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];

然后我将 Root View Controller 设置为 MMDrawerController,如下所示:

[self.window setRootViewController:self.drawerController];

我希望能够在 MMDrawerController 内部发生的所有事情的顶部覆盖一个 View 内的 UIActivityIndi​​cator ,这样我就可以在某些操作完成时使用全局方法使 UI 不可用.

如果 MMDrawerController 是我的 Root View ,我可以在它上面添加一个 View 吗?或者我可以只将 View 添加到其 subview Controller 之一(左抽屉、中心 View Controller 或右抽屉)吗?

谢谢!

最佳答案

ProgressHUD cocoapod 源提供了有关如何执行此 IMO 的提示。基本上,它将进度 View 添加到窗口本身。

- (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,因此它显示了左抽屉 View 的一部分和中心 View 的一部分。果然,HUD 在一切之上,就在屏幕中间,就好像它完全忽略了 child 的观点。

关于ios - 在 MMDrawerController 之上放置一个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25006272/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com