swift - loadViewIfNeeded before iOS 9 -
i need create , load uiviewcontroller
before inserting subview uiviewcontroller
.
in ios 9 mycontroller.loadviewifneeded()
. workaround ios 8?
it seems mycontroller.view.hidden = mycontroller.view.hidden
works seems dangerous hack.
there many ways in can force view controller load view. in fact, common way (as far know) access view
property of view controller.
_ = viewcontroller.view
i wouldn't treat hack. in fact, apple's documentation states accessing view property when equal nil
results in loading requested view. means proposed solution safe , should work intended future releases of ios. apple's documentation:
the view stored in property represents root view view controller's view hierarchy. default value of property nil.
if access property , value nil, view controller automatically calls loadview method , returns resulting view.
Comments
Post a Comment