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.

  1. layering table view / collection view on top of view controller's view. way you're not monkeying main underlying view itself.
  2. having 2 instances of view controller, 1 table , other collection view, , swapping between those.

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -