Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Compass underlaps top bar #6954

Closed
Closed

Description

@1ec5

In a standard view controller with a top bar and automaticallyAdjustsScrollViewInsets set to YES, the compass underlaps the top bar:

underlap

This is almost certainly a regression from iOS SDK v3.3.x. Relevant PRs from this release cycle: #6216 #6313 #6566.

/cc @boundsj @incanus

Activity

  1. added
    iOS
    on Nov 8, 2016
  2. added this to the ios-v3.4.0 milestone on Nov 8, 2016
  3. 1ec5 commented on Nov 8, 2016

    @1ec5
    ContributorAuthor

    This is causing KIF tests to fail:

    Test: testBottomLayoutGuide in MapViewTests failed on iPhone 7
    Assertions: ((CGRectIntersectsRect(logoBugFrame, toolbarFrame)) is false) failed - logo bug should not be under toolbar
    File: MapViewTests.m:386
    
    Test: testTopLayoutGuide in MapViewTests failed on iPhone 7
    Assertions: ((CGRectIntersectsRect(compassFrame, navigationBarFrame)) is false) failed - compass should not be under navigation bar
    File: MapViewTests.m:359
    
  4. frederoni commented on Nov 10, 2016

    @frederoni
    Contributor

    I think this occurs because we don't handle device rotation properly or there's a bug in the topLayoutGuide.

    The initial height of the topLayoutGuide is 64, rotate to landscape and it's 44, rotate back to portrait and we have 52. Additional rotations from here will switch between 44 and 52.

    Here's two workarounds:

    1. Respond to "device rotation" in the view controller

    // MBXViewController.m
    - (void)viewDidLayoutSubviews
    {
        [super viewDidLayoutSubviews];
        [self.mapView setNeedsLayout];
    }

    2. Generate device orientation notifications in MGLMapView

    // MGLMapView.m
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name:UIDeviceOrientationDidChangeNotification object:nil];
    
    - (void)deviceOrientationDidChange:(NSNotification)notification
    {
        [self setNeedsLayout];
    }

    I'd prefer none of the above so I'll dig a bit more. 🐰 🕳

  5. frederoni commented on Nov 10, 2016

    @frederoni
    Contributor

    Decided to go with the latter because it works well and it's a fix in the SDK unlike the first workaround. Implemented in #7004

  6. 1ec5 commented on Nov 10, 2016

    @1ec5
    ContributorAuthor

    I think this may be a duplicate of #6755.

    In #6776, @friedbunny noted that the compass positioning is likely due to a UIKit bug in iOS 10 rather than a regression on our end. However, his proposed fix had some problems too. @frederoni, can you reconcile the two PRs?

  7. frederoni commented on Nov 15, 2016

    @frederoni
    Contributor

    Fixed in #6776

  8. reopened this on Nov 15, 2016
  9. 1ec5 commented on Nov 15, 2016

    @1ec5
    ContributorAuthor

    #6776 doesn’t fix #1327 and actually causes another KIF test to fail:

    Test: testBottomLayoutGuide in MapViewTests failed on iPhone 7
    Assertions: ((CGRectIntersectsRect(logoBugFrame, toolbarFrame)) is false) failed - logo bug should not be under toolbar
    File: MapViewTests.m:386
    
    Test: testInsetMapView in MapViewTests failed on iPhone 7
    Assertions: ((CGRectIntersectsRect(compassFrame, mapViewFrame)) is true) failed - compass should lie inside shrunken map view
    File: MapViewTests.m:423
    
    Test: testTopLayoutGuide in MapViewTests failed on iPhone 7
    Assertions: ((CGRectIntersectsRect(compassFrame, navigationBarFrame)) is false) failed - compass should not be under navigation bar
    File: MapViewTests.m:359
    

    I disagree with @frederoni’s claim in #6776 (comment) that the developer needs to explicitly set automaticallyAdjustsScrollViewInsets to NO if they intend to make MGLMapView not extend to the edges of the screen. This isn’t how MKMapView works.

  10. frederoni commented on Nov 21, 2016

    @frederoni
    Contributor

    Fixed in #7084

  11. 3 remaining items

  12. incanus commented on Jan 11, 2017

    @incanus
    Contributor

    That's weird; shouldn't the topLayoutGuide itself be updated automatically, carrying the constraint along with it?

  13. 1ec5 commented on Jan 11, 2017

    @1ec5
    ContributorAuthor

    #7084 removed the code that conditionally constrains the ornaments to the layout guides. Instead, the ornaments are always constrained only to MGLMapView itself. This is exactly the bug this test was designed to catch.

  14. frederoni commented on Jan 17, 2017

    @frederoni
    Contributor

    This regressed in ede1e71 but we can't just revert it because:
    1: The components should respect the contentInset.
    2: viewController.view is the developers responsibility and we should not modify its constraints.

  15. incanus commented on Jan 17, 2017

    @incanus
    Contributor

    2: viewController.view is the developers responsibility and we should not modify its constraints.

    Coming into this a little cold, but we've long (years) had to touch the view controller view constraints for the compass to solve issues like this. Because we don't want to force users to use a view controller that we mandate, we've searched the responder chain to find the map view's first view controller ancestor in order to solve compass underlap problems.

  16. 1ec5 commented on Jan 17, 2017

    @1ec5
    ContributorAuthor

    I think @frederoni’s point is that, even though we may need to access the view controller’s constraints, we shouldn’t be manipulating them; instead, we should manually move the ornaments around based on the layout guides’ current values. This makes me wonder whether we should ultimately be constraining the ornaments to the map view’s margins instead of its actual edges.

    In any case, since the remaining issue regressed in v3.3.1, it sounds like we should postpone #7716 until v3.4.1 to avoid any last-minute bugs around KVO.

  17. modified the milestones: , ios-v3.4.0 on Jan 17, 2017
  18. modified the milestones: ios-v3.5.0, ios-v3.4.1 on Jan 24, 2017
  19. 1ec5 commented on Jan 24, 2017

    @1ec5
    ContributorAuthor

    Postponing to v3.5.0 because we’ve apparently shipped imperfect behavior around this scenario even before v3.4.0 and the fix would be risky enough to require a beta release.

  20. removed their assignment
    on Mar 10, 2017
  21. modified the milestones: ios-v3.6.0, ios-v3.5.0 on Mar 13, 2017
  22. 1ec5 commented on May 23, 2017

    @1ec5
    ContributorAuthor

    Fixed in #7716 on the release-ios-v3.6.0-android-v5.1.0 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugiOS

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions