【发布时间】:2013-10-11 10:10:48
【问题描述】:
我在另一个上添加了一个新的 UIWIndow 来显示一个视图,但它没有显示任何内容并且屏幕变得有点模糊。代码如下:
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;
我做错了什么?
【问题讨论】:
-
为什么要添加这行
viewController = nil;? -
删除最后两行也没有任何影响
-
看看这里。它应该让你更接近于做像stackoverflow.com/questions/1189078/…这样的事情
-
你增加了窗位吗? window.windowLevel = UIWindowLevelAlert + 1
标签: ios objective-c uiwindow