Skip to content

Conversation

@sabrinaip
Copy link

A new UIToolbarContentView is added during layoutSubviews each time. When users reload the view, the newly created UIToolbarContentView requires disabling again. This pull request takes away the local static variable toolbarContentViewEnabled, since a check is required each time. It also only checks if the last subview is of class _UIToolbarContentView since the UIToolbarContentView is always added last.

}
}
toolbarContentViewEnabled = NO;
UIView *lastView = [self.subviews lastObject];
Copy link
Owner

Choose a reason for hiding this comment

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

How do we know that the last object will always be _UIToolbarContentView?

Copy link
Author

@sabrinaip sabrinaip Dec 21, 2017

Choose a reason for hiding this comment

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

I actually can't find much documentation on how _UIToolbarContentView is added (so I can't say 100% that this will always be last) - however, it always appears last when setting a breakpoint. Multiple solutions found online to this bug all check for _UIToolbarContentView as the last object. Additionally, self.subviews have all other views in init, but a _UIToolbarContentView is added in layoutSubviews. I'm assuming there are no other views added afterwards

Copy link
Owner

Choose a reason for hiding this comment

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

Hmm can you do a backwards loop and place the conditional inside? If the _UIToolbarContentView is found we can early terminate and if it's not it'll still loop through and find it. This way in case anything changes it'll work no matter what.

@schun93 schun93 merged commit 8ec5c87 into schun93:master Dec 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants