skip to Main Content

I want to use tableview inside scrollview. and I want to give height to the tableview as 150 or greater than but as soon as I am doing so It’s showing error. My actually I have to implement collasible cell in the tableview. So I do’t want to give height of the table programatically. I want it should be adjustable by storyboard.

enter image description here

2

Answers


  1. I think your method is not efficient. cz tableview scrollable to, why do you need scroll view. let’s make it simple,
    try this :

    1. create tableview with 4 section
    2. create a view each section (workoutnamecell, workoutlistcell, buttonaddcell, and notecell)
    3. and on function tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath), you will append list off workout list rows. it will make your tableview dynamic

    if you don’t want use tableview only, make tableview and scrollview high contsraint dinamicly. make sure your scrollview high is higher than your tableview. and last disable userinteraction on your tableview. so your tableview will stack on your scrollviw.

    Thanks, CMIW

    Login or Signup to reply.
  2. A UITableView within a UIScrollView is never a good idea. It can lead to many problems. My suggestion would be:

    1. Either make the whole thing a UITableView with all the items currently in the scrollview beeing inside UITableViewCells
    2. Or use a vertical UIStackView that you will dynamically update to expand / collapse rows instead of a UITableView and have that in your scrollview.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search