Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TableViewCell width #295

Closed
aleene opened this issue Jan 27, 2017 · 7 comments
Closed

TableViewCell width #295

aleene opened this issue Jan 27, 2017 · 7 comments
Labels

Comments

@aleene
Copy link
Owner

aleene commented Jan 27, 2017

The width of the cell is still wrong on start up. The multiple reload do not really solve the issue.

@aleene aleene added the bug label Jan 27, 2017
@aleene
Copy link
Owner Author

aleene commented Jan 27, 2017

Re move several reloadData without adverse effect. Except for the nutrients page

@aleene
Copy link
Owner Author

aleene commented Jan 27, 2017

Seems it has to do with loading a pageviewcontroller directly. if I swipe between pageviewcontroller all seems well. The pageViewController container has the correct size.

@aleene
Copy link
Owner Author

aleene commented Jan 27, 2017

It seems that the pageview container is not aware it is in a detail view. It assumes the entire screen.

@aleene
Copy link
Owner Author

aleene commented Jan 27, 2017

Note that the tableview header are ok and the other fields as well. Only the TagListViews are wrong!!!

@aleene
Copy link
Owner Author

aleene commented Jan 27, 2017

@aleene
Copy link
Owner Author

aleene commented Jan 28, 2017

In summary, first some context. I have a very complex setup for my UITableViewController. It is in a UIPageViewController, which is in a UINavigationController, which is de DetailController of a MasterDetailViewController. No worry this all works.

Changing pages in the UIPageViewController, i.e. reloading a UITableViewController can happen in different ways, either by directly accessing a page, or by swiping between pages. The tableView has two types of cells: either dynamic custom defined in te Storyboard, or dynamic custom defined in code. The Storyboard cells have always the right widths, the code cells not.

When loading the pages on a iPad, the Frame widths (view, cell) are incorrect. They are those of the Storyboard or of the device, not of de detail view. Reloading the page with a swipe corrects the widths. Direct loading reverts the widths. (by the way, no problem with the cell heights).

There have been several suggestions:

  • readjust in the cell with (does NOT work):
        cell.setNeedsUpdateConstraints()
        cell.updateConstraintsIfNeeded()
  • add an extra reload in viewDidAppear (does NOT work):
    self.tableView.reloadData()
  • preferredMaxLayOutWidth is only relevant to labels (does NOT work)
  • setting frame.size.width to the width of the tableview, sets the right width, but the cell needs to be repainted;
  • repaint in viewDidAppear() (does NOT work):
        tableView.reloadData()
        tableView.setNeedsLayout()
        tableView.layoutIfNeeded()
        tableView.reloadData()
  • repaint special (does NOT work):
tableView.reloadData()
UIView.setAnimationsEnabled(false)
tableView.beginUpdates()
tableView.endUpdates()
UIView.setAnimationsEnabled(true)

It seems to be a repaint issue, but the problem is where I should do this?

@aleene
Copy link
Owner Author

aleene commented Jan 28, 2017

I noticed that the cell has the right width when it will be displayed, but not when it is created. And this interferes with setting up the cell. Fortunately the tableView is correct, so I can force that width onto the cell with
cell.width = tableView.frame.size.width
And then all is well.

@aleene aleene closed this as completed Jan 28, 2017
aleene added a commit that referenced this issue Jan 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant