• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Put UICollectionView within UITableViewCell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Put UICollectionView within UITableViewCell


  • Subject: Re: Put UICollectionView within UITableViewCell
  • From: "Gary L. Wade" <email@hidden>
  • Date: Fri, 09 Mar 2018 08:21:34 -0800

I would suggest rethinking the table view enclosure and just use a collection
view with headers and footers by way of the supplemental views.
--
Gary L. Wade
http://www.garywade.com/

> On Mar 9, 2018, at 8:00 AM, Glen Huang <email@hidden> wrote:
>
> Hi,
>
> I asked a question about putting UICollectionView within UITableViewCell on
> Apple Developer Forums (https://forums.developer.apple.com/thread/98176), but
> it doesn’t get many replies. I’m not sure if it’s ok to repost the question
> here. I apologize if it’s not.
>
> Here is the question:
>
> Hi, I'm trying to create a table view with cell content like this
>
> | Label                                                 |
> | CollectionItem 1   CollectionItem 2  CollectionItem 3 |
> | CollectionItem 4                                      |
>
> Collection view item should auto wrap at cell end, both the collection view
> and table view use automatic height.
>
> I can somewhat achieve this effect by doing:
> put the label and the collection view in a vertical stack view, make the
> stack view's each edge touch table cell's corresponding edge.
> disable collection view scrolling.
> collection view's intrinsicContentSize returns layout's
> collectionViewContentSize value.
> in table cell's prepareForReuse method, I make the collection view reload its
> data.
>
> But the problem comes when each table cell can contain different number of
> collection items: some table view cells have incorrect heights, clipping its
> collection view. My guess is that when table cells get reused, they don't
> take collection view's new intrinsicContentSize into account.
>
> I tried calling sizeToFit/layoutIfNeeded/updateConstraints in cell's
> prepareForReuse method, none of them works.
>
> If I replace the collection view with a multiline label, and make each cell
> contain different length of text, the cells all have correct heights.
>
> I wonder why label are able to correctly resize cells? how can I make
> collection views do the same?
>
> Thanks very much.
>

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Put UICollectionView within UITableViewCell (From: Glen Huang <email@hidden>)

  • Prev by Date: Re: Put UICollectionView within UITableViewCell
  • Next by Date: Re: Put UICollectionView within UITableViewCell
  • Previous by thread: Re: Put UICollectionView within UITableViewCell
  • Next by thread: Using NSFetchedResultsController with many-to-many relationship
  • Index(es):
    • Date
    • Thread