keywindow is not working in ([[[UIApplication sharedApplication] keyWindow] addSubview:myView];) iOS 6

2.9k views Asked by At

I am using below code to display a window over movie player controller:

[[[UIApplication sharedApplication] keyWindow] addSubview:myView];

Its working fine in iOS 5 but it stopped working in iOS 6. Even window is not displaying in iOS 6. So please can you suggest me the solution for this.

Thanks

4

There are 4 answers

1
Krishna Kumar On

try this:

[[self window] makeKeyAndVisible];

[[[UIApplication sharedApplication] keyWindow] addSubview:view];
1
alecnash On

Add [self.window makeKeyAndVisible] to your AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 

method and you can use this code

[[[UIApplication sharedApplication] keyWindow] addSubview:view];

to your

- (void)viewDidAppear:(BOOL)animated

method in your ViewController

0
Roman Filippov On

[[UIApplication sharedApplication] keyWindow] // available only on main thread

0
wangrui On

Try it after "appdidFinishLaunching:" finished! May solve it.