gpt4 book ai didi

ios - 添加多个 UIWindow

转载 作者:塔克拉玛干 更新时间:2023-11-01 19:09:19 25 4
gpt4 key购买 nike

我在另一个 UIWIndow 上添加了一个新的 UIWIndow 以显示一个 View ,但它没有显示任何内容,而且屏幕变得有点模糊。这是代码:

UIWindow* topWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
[topWindow setWindowLevel:UIWindowLevelNormal];

CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;

UIViewController* viewController = [[UIViewController alloc] init];
UIView* overlay = [[UIView alloc] initWithFrame:CGRectMake(0, -statusBarHeight, viewController.view.frame.size.width, statusBarHeight - 1)];
[overlay setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[overlay setBackgroundColor:[UIColor whiteColor]];
[viewController.view addSubview:overlay];
[topWindow setRootViewController:viewController];

[topWindow setHidden:NO];
[topWindow setUserInteractionEnabled:NO];
[topWindow makeKeyAndVisible];

viewController = nil;

overlay = nil;

我做错了什么?

最佳答案

我也想像你一样。

@implementation TAAppDelegate {
UIWindow *win;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.

double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
win = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
win.rootViewController = [UIViewController new];
win.rootViewController.view.backgroundColor = [UIColor whiteColor];
win.rootViewController.view.alpha = 0.5;
[win makeKeyAndVisible];
});
return YES;
}
.....

我做到了。我认为您应该保留新的 UIWindows。 (我正在使用 ARC,所以我定义了 1 个本地变量来保留它)

祝你好运!

关于ios - 添加多个 UIWindow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19315559/

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