I want to limit number of rows in tableView say I want to show only 2 rows initially and if user clicks "See All" button then display all the rows. The data (array) for tableView is coming from CoreData. I have entered (saved) all the data in another ViewController, and fetching data on some another ViewController. There might be a case where data may be nil. Currently, I’m displaying all the rows just like –> return array.count, but I have no idea how to achieve my condition ?
2
Answers
You just need a property to indicate whether you want to show all rows or not.
In your
numberOfRowsInSection
data source method you check that value:Then your button handler needs to update
showAllRows
and reload the table view.Declare a boolean variable,
On more click trigger an event like