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

[ios] Fix issue wrong position of attribution dialog after rotation #14185

Merged
merged 3 commits into from
Apr 11, 2019

Conversation

lloydsheng
Copy link
Contributor

@lloydsheng lloydsheng commented Mar 21, 2019

The PR fixed #12897

@lloydsheng lloydsheng requested a review from a team March 21, 2019 09:32
@julianrex
Copy link
Contributor

@lloydsheng thanks for this, can you please look at #13530 and see how that compares. That uses PR uses UIPopoverPresentationControllerDelegate methods to reposition.

@lloydsheng
Copy link
Contributor Author

lloydsheng commented Mar 22, 2019

@julianrex The PR considered not only orientation changing. but also the attribution position changing and proper arrow direction for the popoverPresentationController.

@tobrun tobrun added the iOS Mapbox Maps SDK for iOS label Apr 2, 2019
@julianrex
Copy link
Contributor

Looking at the docs for -popoverPresentationController:willRepositionPopoverToRect:inView:

The popover presentation controller calls this method in response to interface changes that require a new size for the popover. For example, UIKit calls this method when the popover must be resized to make room for the keyboard. You can use this method to obtain the new size of the popover and optionally to make changes to the proposed view and rectangle.

I'm wondering if there are similar cases where the popover will need to be moved to accommodate a system view that we're not considering. Can you think of any? We may want to use this delegate method in addition to repositioning the popover when attribution location changes.

Thoughts?

@lloydsheng lloydsheng force-pushed the lloyd-attribution-alertview branch from bd6fc9a to 8c76bf8 Compare April 10, 2019 06:29
@lloydsheng
Copy link
Contributor Author

@julianrex Here are all cases I can find which the alertview's position needs to be updated:

  1. When the keyboard show
    • Trigger -popoverPresentationController:willRepositionPopoverToRect:inView:
  2. When the interface orientation changes
    • Trigger -popoverPresentationController:willRepositionPopoverToRect:inView:
    • Trigger -layoutSubviews
  3. When the mapview size changes
    • Trigger -layoutSubviews
  4. When the position of the attribution button changes
    • Trigger -layoutSubviews

As you can see the only case I found which won't trigger layoutSubviews of the mapbview is the case #1. But the default behavior of UIKit handles it well as the docs said:

If you do not implement this method in your delegate, UIKit resizes the popover to the specified rectangle and moves it (as needed) to the specified view.

That's why I choose the current implementation.

Copy link
Contributor

@julianrex julianrex left a comment

Choose a reason for hiding this comment

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

Thanks for double checking!

@julianrex julianrex added this to the release-mojito milestone Apr 10, 2019
@julianrex
Copy link
Contributor

Please can you add an entry to the change log.

@lloydsheng lloydsheng force-pushed the lloyd-attribution-alertview branch from 8c76bf8 to ac15f1a Compare April 11, 2019 08:02
@lloydsheng lloydsheng changed the title Fix issue wrong position of attribution dialog after rotation [ios] Fix issue wrong position of attribution dialog after rotation Apr 11, 2019
@lloydsheng lloydsheng merged commit 8c5c4dd into master Apr 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong position of attribution dialog after rotation on iPad
3 participants