Status bar and navigation bar issue in IOS7

前端 未结 11 1945
眼角桃花
眼角桃花 2020-11-22 10:10

I am migrating my application to iOS 7. For handing the status bar issue I have added this code

if([[[UIDevice currentDevice] systemVersion] floatValue] >         


        
11条回答
  •  情书的邮戳
    2020-11-22 10:14

    With Salesforce SDK 2.1 (Cordova 2.3.0) we had to do the following to get the status bar appear on the initial load of the App and coming back from the background (iPhone and iPad):

    Contrarily to other solutions posted here, this one seems to survive rotation of the device.

    1-Create a category of theSFHybridViewController

    #import "SFHybridViewController+Amalto.h"
    
    @implementation SFHybridViewController (Amalto)
    
    - (void)viewWillAppear:(BOOL)animated
        {
            //Lower screen 20px on ios 7
            if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
                CGRect viewBounds = self.view.bounds;
                viewBounds.origin.y = 20;
                viewBounds.size.height = viewBounds.size.height - 20;
                self.webView.frame = viewBounds;
            }
    
        [super viewWillAppear:animated];
        }
    
        - (void)viewDidLoad
        {
    
            if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
                CGRect viewBounds = self.view.bounds;
                viewBounds.origin.y = 20;
                viewBounds.size.height = viewBounds.size.height - 20;
                self.webView.frame = viewBounds;
            }
            [super viewDidLoad];
        }
    
    @end
    

    2-Add to AppDelegate.m imports

    #import "SFHybridViewController+Amalto.h"
    

    3-Inject at the end of of method didFinishLaunchingWithOptions of AppDelegate

    //Make the status bar appear
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
    
        [application setStatusBarStyle:UIStatusBarStyleLightContent];
        [application setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
    }
    

    4-Add to App-Info.plist the property

    View controller-based status bar appearance with value NO

提交回复
热议问题