I have a project with a button that allows the user to switch between list view (UITableView) and grid view (UICollectionView) but I don’t know how to do it.
I have a project with a button that allows the user to switch between
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Let’s suppose that your controller has a
UITableViewproperty namedtableViewand aUICollectionViewproperty namedcollectionView. In yourviewDidLoadyou need to add the starting view. Let’s suppose it’s the table view:Then in your button callback, swap the views out:
If you want a fancy animation, you can use
+[UIView transitionFromView:toView:duration:options:completion:]instead: