3

ビューを表示するために新しい 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;

私は何を間違っていますか?

4

3 に答える 3

4

私もあなたのようになりたいです。

@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つのローカル変数を定義しました)

幸運を!

于 2014-03-06T03:19:43.953 に答える
2

windowLevel プロパティを別の値に設定します。私は通常使用します:

topWindow.windowLevel = UIWindowLevelAlert + 1;
于 2013-10-11T10:20:18.387 に答える