ios - Changing root view of view controller ends up with a black view -
what i'm trying achieve view controller can display items in both list form , collection form button can switch on between 2 display options.
so i've implemented uiviewcontroller
can hold both uitableview
, uicollectionview
.
when view controller loads @ first time, uitableview
appears fine. when press switching button (it changes self.view
uicollectionview
), ends black view.
and when try uitableview
pressing switching button (again, changes self.view
previous uitableview
), nothing happens. stays black.
is there should after changing root view of view controller?
it not recommended behavior change view of uiviewcontroller
past point in time @ loadview
called. you'll want view controller have one, persistent view lifetime. i'd recommend 1 of following.
- layering table view / collection view on top of view controller's view. way you're not monkeying main underlying view itself.
- having 2 instances of view controller, 1 table , other collection view, , swapping between those.
Comments
Post a Comment