Add view controllers to the container hierarchy, and implement didMoveToWindow hook.#2
Open
carllindberg wants to merge 1 commit intoCollect3:masterfrom
Open
Conversation
… container-based settings use them in their UIAppearanceContainer list. Add a note for the correct place to add a UIPopoverController, if possible. Had to add an additional place where the container-based appearances are applied, as it is possible for a view to be added to a superview first, and only later have the superview added to another superview (changing the potential hierarchy), and willMoveToSuperview: will not be called in that scenario. Used didMoveToWindow as a hook to apply additional hierarchy-based appearance calls.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request has a couple of related changes, needed to make things work in one application I'm working on.
First, UIViewControllers are UIAppearanceContainers, but were not being added to the container list, so a few of my appearance proxies were not being applied since they were never matched. I did that by mixing in the view controllers in the container list right after the view it was controlling.
Additionally, it is best to add the UIPopoverController at the end, if applicable. I don't know of any public API to do that, and we have a private mechanism to determine the popover for at least most of the popovers in our app, so that is what I used locally. For this, I just added a comment in the right spot to add the popover if it can be determined.
We also had a situation where views were added into a container view (thus getting all of the willMoveToSuperview: calls at this point), but only later was the container added to a superview itself. In this situation, the hierarchy changes greatly, meaning more appearance proxies should come into play, but there was nothing to catch this, I don't think. I added an implementation of didMoveToWindow, to re-apply the hierarchy-based appearance proxies again if necessary. This is particularly necessary in the case of UITableViewCells, which are often configured before being returned to the UITableView from the data source methods, and which only get added as a subview later on.
This seems to catch the conditions we needed, though I am a little concerned that any UIBar[Button]Item appearance proxies are never getting applied. I have not yet found a place where that is hurting us, but that might require some additional work if so. Also, in the core "apply" method, for some particular UISegmentedControls I had to add a "[view setNeedsLayout]; [view layoutIfNeeded]" right after applying the appearance proxies in order to get the font to redisplay right (it was displaying with the old font until the user clicked on it). That may have been something particular to our app so I did not include that code here.