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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -