简体   繁体   中英

Swift: How can i put cells together and adjust the cell width of a TableView depending on the amount of text

I am familiar with TableView/CollectionsView and TableViewCells/CollectionsViewCells and loading data onto them.

I am however facing a challenge, I have an array of sentences and i'm hoping to achieve the design below.

https://imgur.com/a/bI2qNDy

Think of it as though you are reading a book and each cell contains a sentence. So you would want a sentence to start after a full stop and not in a new line. Image should explain what i'm trying to achieve. In this case a cell should start when one cells ends.

So i'm not sure on how to approach this challenge. If you could please share your suggestions.

I have successfully loaded the data into the tableview and collectionview and i have tried adjusting the size of the cells. However, the cells are not wrapping.

You can achieve that with UICollectionView using custom Flow layout. Here it is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM