gpt4 book ai didi

ios - UInavigationcontroller 全局警报消息(如 WhatsApp 传入消息)

转载 作者:行者123 更新时间:2023-11-29 13:10:03 25 4
gpt4 key购买 nike

正在构建一个应用程序(论坛)并且我有一个 UINavigationController。我想在用户所在的任何 UIViewController 中显示一条警告消息。我真的不知道该怎么做。

非常感谢您的帮助。

这里是我想做的一些例子:这是样本 screenshot

最佳答案

您可以将此 View 添加到 keyWindow 中,并将其置于最前面。或者你可以把你的 alertView 做成一个 UIWindow,这样你就可以在任何地方显示它。

static UIWindow *_sharedNavigationBarAlertView = nil;
+ (UIWindow *)sharedNavigationBarAlertView
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedNavigationBarAlertView = [[UIWindow alloc] initWithFrame:CGRectZero];
_sharedNavigationBarAlertView.windowLevel = UIWindowLevelStatusBar + 1.0;
_sharedNavigationBarAlertView.hidden = YES;
// add other views...
});
return _sharedNavigationBarAlertView;
}

+ (void)showWithInformation:(id)info
{
// [self sharedNavigationBarAlertView].imageView.image = ...;
// [self sharedNavigationBarAlertView].titleLabel.text = @"";
// [self sharedNavigationBarAlertView].detailLabel.text = @"";
CGRect frame = [UIScreen mainScreen].bounds;
frame.size.height = 44.0;
[self sharedNavigationBarAlertView].frame = frame;
[self sharedNavigationBarAlertView].hidden = NO;
}
+ (void)hide
{
[self sharedNavigationBarAlertView].hidden = YES;
}

// To release the shared alert window, just set it to nil

关于ios - UInavigationcontroller 全局警报消息(如 WhatsApp 传入消息),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17599619/

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