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

Revert KVO triggered manual layout of map ornaments #9995

Conversation

boundsj
Copy link
Contributor

@boundsj boundsj commented Sep 13, 2017

Fixes #9941

This essentially reverts #7716 in favor of a constraint system for laying out MGLMapViews's ornamental views that is very similar to the one originally implemented in #1328 that fixed #1327

It attempts to mix in the things we learned along the way in:

#3697
#6776
#6954
#7084

This includes respecting content insets when the constraints are created.

While I was there, I went ahead and added 2c757c7 that uses iOS 11's new Safe Guide instead of top and bottom layout guides and the layout anchor constraint APIs instead of +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]. This simplifies the layout code a lot. Pre-iOS 11 logic has been pulled into -[MGLMapView updateConstraintsPreiOS11] and can be deleted -- someday!

I updated KIF and OHHTTPStubs to resurrect the UI tests in my environment for Swift 3. Using Xcode 8.3.3 and an iOS 10 simulator, this PR passes the following UI tests in MapViewTests:

  • testTopLayoutGuide
  • testBottomLayoutGuide
  • testInsetMapView
  • testContentInsetsWithTinyMapView

I was unable to run tests using Xcode 9 (beta/GM) and iOS 11 although I did manually verify that the iOS 11 style constraint system works using an iOS 11 (GM) device and that the fallback to to pre-iOS 11 constraints works as expected if the SDK is compiled with Xcode 9 (iOS 11 SDK) and run on a pre-iOS 11 phone.

@boundsj boundsj added crash iOS Mapbox Maps SDK for iOS labels Sep 13, 2017
@boundsj boundsj added this to the ios-v3.6.3 milestone Sep 13, 2017
@boundsj boundsj self-assigned this Sep 13, 2017
@boundsj
Copy link
Contributor Author

boundsj commented Sep 13, 2017

Now that #9876 has landed, this PR will need to be rebased. cc @jmkiley

UIViewController *viewController = self.viewControllerForLayoutGuides;

if (_isObservingTopLayoutGuide) {
[(NSObject *)viewController.topLayoutGuide removeObserver:self forKeyPath:@"bounds" context:(void *)&MGLLayoutGuidesUpdatedContext];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: MGLLayoutGuidesUpdatedContext can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙇 fixed in 0a19195

Copy link
Contributor

@friedbunny friedbunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, really glad you also hit the safe area stuff.

simulator screen shot - iphone x - 2017-09-14 at 12 24 44

This reverts the manual layout triggered by KVO approach in favor of a constraints based approach that the KVO method had previously replaced. Although the manual layout approach worked well in most cases and was cleaner in that it did not manipulate any containing views in the app space, using KVO on UIViewControllers has proven to be dangerous.

This also updates the gitshas for KIF and OHHTTPStubs to unbreak UI tests that verify these related changes are working.
@boundsj boundsj force-pushed the boundsj-revert-manual-ornament-layout branch from 2c757c7 to 611e6ce Compare September 14, 2017 17:56
@boundsj
Copy link
Contributor Author

boundsj commented Sep 14, 2017

Most checks are failing now when trying to download dependencies from s3 (which is currently having major issues). I'll try again later.

@boundsj boundsj force-pushed the boundsj-revert-manual-ornament-layout branch from 0a19195 to 8433723 Compare September 14, 2017 20:20
@boundsj boundsj merged commit a6224ab into release-ios-v3.6.0-android-v5.1.0 Sep 14, 2017
@boundsj boundsj deleted the boundsj-revert-manual-ornament-layout branch September 14, 2017 20:51
mappy-mobile pushed a commit to Mappy/mapbox-gl-native that referenced this pull request Oct 3, 2017
….1.4

* release-ios-v3.6.0-android-v5.1.0: (36 commits)
  [android] [auto] Update properties to version 5.1.4 in preparation for build.
  [android] - latLngBounds test
  [android] - update changelog for 5.1.4 release.
  bump MAS version number to 2.2.3 (mapbox#9901)
  [android] fix is download complete (a download is complete when count and required resources match and the download state is inactive) (mapbox#9913)
  [android] - avoid adding duplicate points to bounds
  [android] Clear out mapCallback's OnMapReadyCallbacks on onDestroy
  [android] - harden offline region deletion
  Do not check connection if it is local request
  [android] - disable rotation gesture when pinch zooming
  macos-v0.5.1
  [ios] Bump podspec to 3.6.4 (mapbox#10059)
  [android, ios, macos] Updated translations
  [core] make sure tiles are not treated as complete until all worker operations completed
  [core] keep tiles renderable even if a subsequent error occurs
  [ios] Be sure to get a BOOL value for nullable dict keys
  iosv3.6.3 podspec bump (mapbox#10008)
  [ios, macos] Deprecate trafficDayStyleURL and trafficNightStyleURL (mapbox#9918)
  [ios] Use constraints to manage ornament view placement (again)  (mapbox#9995)
  [ios] Canned spam coming from Transifex
  ...

# Conflicts:
#	platform/android/MapboxGLAndroidSDK/proguard-rules.pro
#	platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crash iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants