In Objective-C in the viewDidLoad method of a UIViewController I do this to get the keyWindow reference in my iOS app:
UIWindow * keyWindow = [[UIApplication sh
Don't call window in didLoad function call the keyWindow in viewDidAppear function of ViewController