view.bringSubview(toFront: pickerButton!) is ran in updateImagePickerButton() to ensure that the the button is always on top (visible), regardless of when then imagePickerAdapter's didSet creates the pickerButton.
Why?
The pickerButton is hidden behind the previewView if a custom imagePickerAdapter is set before viewDidAppear.
Footnote:Setting subviews in viewDidAppear is not a great solution... It's a fix to respect Safe Areas (known after viewDidAppear) for iPhone X in particular. Setting positions constrained to Safe Area would allow for more flexibility with Auto Layout, and thus creating the subViews in viewDidLoad/viewWillAppear would be possible again.
What?
view.bringSubview(toFront: pickerButton!)
is ran inupdateImagePickerButton()
to ensure that the the button is always on top (visible), regardless of when thenimagePickerAdapter
's didSet creates the pickerButton.Why?
The pickerButton is hidden behind the previewView if a custom
imagePickerAdapter
is set beforeviewDidAppear
.Footnote: Setting subviews in viewDidAppear is not a great solution... It's a fix to respect Safe Areas (known after viewDidAppear) for iPhone X in particular. Setting positions constrained to Safe Area would allow for more flexibility with Auto Layout, and thus creating the subViews in viewDidLoad/viewWillAppear would be possible again.