Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-1204

CDVViewController-loaded view doesn't respect applicationFrame

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.1, 1.9.0, 2.0.0
    • 2.1.0
    • cordova-ios
    • None
    • Mac OS X Lion, Xcode 4.4, iOS SDK 5.1.

    Description

      If you take the Cordova template app and, instead of using:

      [self.window addSubview:self.viewController.view];

      to display the view in the AppDelegate, you use the more recommended (for iOS >= 4.0) method of:

      self.window.rootViewController = self.viewController;

      to display the view, there is a positioning difference for the web view, due to the fact that, in the latter case, self.viewController.view's frame is not being set at the appropriate time. This sets the view's frame to the entire height and width of the device. I.e. it doesn't account for the space taken up by the status bar. This can be easily verified by making an index.html page with an h1 header at the top, and toggling which code line you use to display the view, from the given lines above.

      The solution to this is to set the view's frame in viewWillAppear in CDVViewController:

      • (void)viewWillAppear:(BOOL)animated
        {
        self.view.frame = [[UIScreen mainScreen] applicationFrame];
        }

      Attachments

        Activity

          People

            shazron Shazron Abdullah
            khawkins@salesforce.com Kevin Hawkins
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified