Search code examples
iphoneiosios6

UI is disturb due to default call in iphone


My application have calling functionality. When making call,it goes to default phone app. Now during on going call, I am accessing my app, at that time my app shows green bar over navigation bar. If I go to next detail screen, all UI is getting disturbed.


Solution

  • You have three choices here to fix your VC UI:

    Firs: you can set up the autoresize masks in code or strotyboard.

    Second: use didChangeStatusBarFrame:

    - (void)application:(UIApplication *)application didChangeStatusBarFrame:(CGRect)newStatusBarFrame {
        if ([UIApplication sharedApplication].statusBarFrame.size.height == 40) {
            // Do adjustment
        }
        else if  ([UIApplication sharedApplication].statusBarFrame.size.height == 20 && oldStatusBarHeight == 40){ // you should keep oldStatusBarHeight 
            // Do adjustment
        }
        else {
            return;
        }
    }
    

    Third: register for a Change StatusBarFrame notification in your viewDidLoad:

     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameChanged:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameWillChange:) name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
    

    And adjust your VC size in statusBarFrameWillChange and statusBarFrameChanged.