I'm trying, with no success yet, to add a UiCollectionView to a static UITableViewCell and have it resize the tableViewCell vertically as the numbers of items in the collection grows. Is this even possible or is there a better solution to this problem?
Add height constraint in collectionview through storyboard and declare an iboutlet of class NSLayoutconstraint in tablecell for that constraint. In your tableview cell data configuration code change the constant value of that property to collectionview's contentsize.height. This will force the collectionview to increase its height which interns will force the cell to increase its height.
You can call .contentSize on the collection view to get is't size, and set that size for the UITableViewCell size.
Related
I select UITableViewCell with also create xib file.
When I create custom tableViewCell with xib, I see contentView height is 0,5 point less than tableViewCell height.
How do I make the contentView height same to cell height?
I believe the 0.5 is to account for the separator automatically applied to cell in a uitableview.
I have a UITableView with cells that have inside a UICollectionView.
Now all works great except of UICollectionViewCell scrolling i want that the height of table view cell follow the Collection view cell content.
In simple word i want scrolling in table view but not inside single cell i need to display all contents of UIcollectionViewCell without scrolling inside it.
Thanks
You have to calculate the collectionviews' heights and set a height constraint on each of them. then add top and bottom constraints from the collectionviews to their superviews (the tableviewcells / their contentviews) and let autolayout do its work.
don't forget
tableView.estimatedRowHeight = 44 // or something similar
tableView.rowHeight = UITableViewAutomaticDimension
in the controller's viewDidLoad to make the automatic row height calculation work.
In UITableview I am adding another UIView, it's height should be dynamic according to cell height, the problem I am facing is it is not accurate.
The height of UIView is not varying correctly with cell and it is calculated again and again on table reloading.
When you load your data, you can calculate the each cell's height, and store them in a array, then you can use this frame array to setup the uiview's frame
You have to provide constraints on your UIView according to contentView of cell top,bottom,leading,trailing value 0 , So your UIView height and width is same as cell height & width.
Please refer http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1 for learning autoLayout for beginner.
I have a UICollectionView that has a bunch of cells that contain content of different heights. How can I go about having the cells automatically grow to be the height of their content?
I'm not sure if there is an automatic way of doing this like using UITableViewAutomaticDimension other than using autolayout constraints
What you could do is to create a constraint property
#property (nonatomic, strong) NSLayoutConstraint *heightConstraint;
Then calculate the content size of the cell after creating it and in updateConstraints update the heightConstraint constant
self.heightConstraint.constant = calculatedHeight;
Finally whenever you have updated the content call to setNeedsUpdateConstraints
http://code4app.net/ios/FBLikeLayout/54f17bdbe247418102a8f6e4
Here is a link that shows an example project with different size CollectionCell Heights.
I have tableview frame height is 300. I have created one custom UITableViewCell subclass for adding to UITableView cell. When ever i adding custom cell to tableview, tableview is not increasing the height of frame. Tableview height constant like previous height 300. I want that whenever custom cell is adding the tableview height should be increase. How to resolve this?