Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9186369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:30:37+00:00 2026-06-17T19:30:37+00:00

I have UIViewController (for example, loginVC) and I’m trying to add it’s view on

  • 0

I have UIViewController (for example, loginVC) and I’m trying to add it’s view on top of all views.

I tried to add this view to AppDelegate

[[AppDelegate sharedDelegate].window addSubview:loginVC.view];

But in this case autorotation doesn’t work, so I tried to add this view to NavigationController‘s view. NavigationController is rootViewController:

[[AppDelegate sharedDelegate].navigationController.view addSubview:loginVC.view];

It looks good and autorotating, but it has strange behavior when rotating.

After beginning of rotation, navigation bar is showing on top of loginVC.view and at the end of rotation is going behind this view, like it shown on screenshots (I’ve set red background to make it more visible, background is transparent, to see all stuff behind this view):

enter image description here
enter image description here
enter image description here

What I’ve tried:

  • I found this somewhere on stackoverflow: disable UIView animations before rotating and enable them after rotating – doesn’t look good, because rotating occurs without animation (it’s a bit obvious)

  • tried to make navigationBar hidden before rotation and make it visible after rotation, but in this case navigationBar bringing on top of loginVC.view

Next thing I gonna do – add this view on AppDelegate’s window and handle rotation manually, but maybe there is some better way to do this?

UPD:

screenshots:

enter image description here

enter image description here

enter image description here

You can see issue on second screenshot: navigation bar is on top

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:30:38+00:00Added an answer on June 17, 2026 at 7:30 pm

    My friend helped me with this problem

    Here is the solution:

    In AppDelegate I’ve created UIWindow property:

    //AppDelegate.h
    @property (nonatomic, strong) UIWindow *loginWindow;
    

    Initialized it when application starts

    //AppDelegate.m
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    ....
        self.loginWindow = [[UIWindow alloc] init];
        self.loginWindow.windowLevel = UIWindowLevelStatusBar;
        self.loginWindow.frame = [[UIScreen mainScreen] bounds];
        self.loginWindow.backgroundColor = [UIColor clearColor];
    ....
        return YES;    
    }
    

    And then, in loginVC:

    @interface loginVC ()
    @property (nonatomic, weak) UIWindow *loginWindow;
    @end
    
    @implementation
    ....
    
    - (void)show {
    // setting up loginVC view 
        if (!self.loginWindow) {
              self.loginWindow = [[AppDelegate sharedDelegate] loginWindow];
        }
        if (![self.loginWindow.rootViewController isEqual:self]) {
              [self.loginWindow setRootViewController:self];
        }
        self.loginWindow.hidden = NO;
    //UPD:
        //[self.loginWindow makeKeyAndVisible];
    //UPD2:
        [self.loginWindow makeKeyWindow];
    }
    
    - (void)hide {
    // hiding view and stuff
        [[[AppDelegate sharedDelegate] loginWindow] setHidden:YES];
    //UPD:
        //[[[AppDelegate sharedDelegate] window] makeKeyAndVisible];
    //UPD2:
        [[[AppDelegate sharedDelegate] window] makeKeyWindow];
    }
    @end
    

    UPD:

    No need to use makeKeyAndVisible method of UIWindow, second window will be always on top of first one.

    UPD2:

    Again updating my answer, maybe it will be useful for somebody.

    Without makeKeyAndVisible I couldn’t use UITestFields so I uncommented that code and faced another problem:

    I have UIViewController, create an instance of another UIViewController inside this controller and call [self presentViewController:...]. In presented UIViewController I’m creating loginVC, but when I call

    [[[AppDelegate sharedDelegate] window] makeKeyAndVisible];

    presented viewController disappears, but first view controller still has this controller as presentedViewController, so I can’t present other view controllers.

    My solution was change makeKeyAndVisible on makeKeyWindow.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to add/implement this example to my existing Split View app
I have a UIViewController view as a subview/modal on top of another UIViewController view,
Example: I have 10 view controllers, which are all allocated and initialized in the
I have subclassed UIViewController to provide common functionality for all UIViewControllers (for example I'm
so for example i have this in my uiviewcontroller - (void)loadView { CGRect frame
I have my MainViewController which a UIViewController class, in this view I have a
I have a UIViewController (which sits inside a tabUIController). Within this UIViewController, I want
I have a UIViewController that contains a subview and a UIToolbar. I'm trying to
For example, I have a UIViewController, and have a value: NSString *testString; @property (nonatomic,
I have a UIViewController based app and I want to changes data on view

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.