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

uitableviewcells with accessoryViews #11

Closed
mazz opened this issue Oct 28, 2014 · 1 comment
Closed

uitableviewcells with accessoryViews #11

mazz opened this issue Oct 28, 2014 · 1 comment

Comments

@mazz
Copy link

mazz commented Oct 28, 2014

When a cell has an accessoryView(chevron), this can affect the height of the cell because it will make self.contentView narrower. BUT if you've already calculated the height(using height = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height; ), the cell will get truncated or be too long, depending on WHEN you decide to show the accessoryView. Workaround?

@smileyborg
Copy link
Owner

Unfortunately, this is a limitation of the iOS 7 method of manual cell height calculation. This is one of the reasons why Apple provided the new self sizing cell mechanism in iOS 8, which shouldn't have this issue.

You'll need to manually determine the width of the contentView when the accessory view is showing on a cell, then set the contentView.bounds to this new size and recalculate the height by calling [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;

You may find that it is better to manually add your own "fake" disclosure chevron using an image.

See also:
http://stackoverflow.com/questions/902096/uitableviewcells-contentviews-width-with-a-given-accessory-type

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

2 participants