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

TLTableViewController doesn't configure cells correctly under iOS 8 #36

Closed
fatuhoku opened this issue Sep 2, 2014 · 11 comments
Closed

Comments

@fatuhoku
Copy link

fatuhoku commented Sep 2, 2014

Demo project showing broken cell here: https://github.com/fatuhoku/Demo-TLIndexPathTools-Tables-Broken-Under-iOS8/tree/develop. Tested on Simulator, iPad Air (iOS 8).

Two symptoms:

  • text labels for default styles of UITableViewCell (Basic, Left / Right Detail, Subtitle) are misplaced ios simulator screen shot 2 sep 2014 17 51 20
  • custom styles cause cells to overlap ios simulator screen shot 2 sep 2014 17 54 28

The provided demo project covers the first case.

Using UITableViewController and explicitly wiring it up with TLIndexPathController still works.

@wtmoose
Copy link
Member

wtmoose commented Sep 2, 2014

I'll start looking into iOS8 when my project starts migrating in about a week.

@wtmoose
Copy link
Member

wtmoose commented Sep 14, 2014

Your sample project doesn't compile.

@fatuhoku
Copy link
Author

The sample project uses Cocoapods. Did you run pod install, then open the .workspace file?

Alternatively hook up TLIPT to the project in whatever way you prefer.

@wtmoose
Copy link
Member

wtmoose commented Sep 16, 2014

The method used to automatically calculate cell height in TLTableViewController does not work in iOS8. I don't have a quick fix for this. In the meantime, the workaround I recommend is to override heightForRowAtIndexPath. If all of your cells are default height, then do the following:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return self.tableView.rowHeight;
}

If you're using self-sizing cells, use the above override and add the following:

- (void)viewDidLoad {
    [super viewDidLoad];
    // ...
    self.tableView.rowHeight = UITableViewAutomaticDimension;
}

For other cases, you'll need to use your own logic.

@emrsn-mihailpopa
Copy link

The height issue is solved, but custom cells with left padding (added in layoutSubviews) are reset to 0 padding when I reload data using TLIndexPathTools library.

@wtmoose
Copy link
Member

wtmoose commented Sep 19, 2014

Popa that has nothing to do with this ticket. Furthermore, I doubt it has anything to do with TLIndexPathTools because TLTableViewController doesn't manipulate cells in any way beyond providing a custom heightForRowAtIndexPath implementation. Try posting to StackOverflow and including more details. My guess is you're using Auto Layout wrong, such as manually setting frames in layoutSubviews.

@fatuhoku
Copy link
Author

@wtmoose I've demonstrated in the demo project that using TLTableViewController causes the displacement; if you use a standard UITableViewController (and implement the necessary -tableView:numberOfRowsInSection:and -tableView:cellForRowAtIndexPath methods) without changing anything else, the displacement is not present any more.

I have reproduced this behaviour a moment ago with my project.

At this point in time I'm going for the UITableViewController solution but would like to get to the bottom of this for future work with tables.

@wtmoose
Copy link
Member

wtmoose commented Oct 22, 2014

I acknowledged the issue and suggested a workaround 6 weeks ago and you didn't respond.

As outlined in the readme, you can use a TLIndexPathController in a UITableViewController. You only need to implement one delegate method. If you don't need view controller-backed cells or automatic row height calculations, there is little use for TLTableViewController.

@csotiriou
Copy link

Overriding heighForRowAtIndexPath always works.

I also cannot reproduce the problem with the latest versions, using iOS 8.1. Was this fixed? If yes, maybe it should be closed?

@wtmoose
Copy link
Member

wtmoose commented Dec 13, 2014

@csotiriou this is still an issue in iOS8.1 as can be seen by running the sample project. I think it only affects non-custom cells in universal storyboards. These cells are getting dequeued out of the storyboard with a zero frame, breaking the cell height logic in heighForRowAtIndexPath.

Now that iOS has self-sizing cells, the heighForRowAtIndexPath implementation in TLTableViewController isn't needed anymore. But removing it breaks backward compatibility. And since there's a workaround I haven't removed it. At some point I'll remove it and provide a workaround for backward compatibility.

wtmoose pushed a commit that referenced this issue Apr 8, 2015
See comments in Settings example project
@wtmoose
Copy link
Member

wtmoose commented Apr 8, 2015

Workaround published in 0.3.10. Demonstrated in Settings example project. Comment from Settings project:

In previous versions of TLTableViewController, the logic for heightForRowAtIndexPath
would in certain scenarios dequeue a cell from the storyboard and return that cell's
height. This case is problematic with new storyboards that use size classes because
the dequeued cells have zero height. The new version of heightForRowAtIndexPath
detects this case and returns UITableViewAutomaticDimension instead of zero, which
falls back (or perhaps forward) to the new auto sizing cell behavior.

Note that UITableViewAutomaticDimension appears to have some animation issues. In
particular, the cells below the "volume" cell visibly jump when the "volume" cell
appears. I assume this is related to the cell being taller than the other cells
and the UITableViewAutomaticDimension behavior setting up the animations with
starting values based on the default cell height. The workaround for this issue
was to make the "volume" cell and instance of TLDynamicHeightCell, which causes
TLTableViewController's classic cell height calculation to kick in.

@wtmoose wtmoose closed this as completed Apr 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants