Search code examples
iosobjective-cuitableviewuiswitch

how to hide a table view section on clicking switch in another section in iOS


I am creating same setting page as iOS having and in wifi section when switch is clicked other section of network should hide and vice versa


Solution

  • There are so many possibilities to implement such UI.

    1.Either you can keep both buttons outside or above both tables.So that if you click on button1 you hide first table & show second & when click on second hide second table & show first table.

    OR

    2.In first table add two button at first row as you did.When you click on button1 then instead of hiding first table return 1 for table1 data source in numberofrows method & reload table1, so that buttons will be there & then show second table below first table.When user click on second button then hide second table & return new data source for first table & reload table1.

    OR

    3.Use one table for both data source.At first row there will be two buttons.On clicking on them reload table accordingly.