uicollectionviewcell

How to create horizontally dynamic UICollectionView cells? Swift

我怕爱的太早我们不能终老 提交于 2019-12-02 02:23:20
Hey I'm trying display a set of "tags" in a view controller using collection view cells but I'm having trouble finding a way to make them be able to dynamically resizable depending on the length of the string. Right now the individual cells are statically sized so whenever a String that populates the cell with characters exceeding the size of the cell, it goes into the second line. I want it so that the cell can change length depending on the length of the String. So if it's the tag "#Vegan", it will automatically resize so that the tag isn't that big. Likewise, if it's a longer string like "

Play video in the collection view cell like the videos playing in the Facebook app Timeline

寵の児 提交于 2019-12-02 02:22:29
问题 I want to play video in the collection view cell,the requirement is like the instagram timeline and playing video is like playing videos in the facebook time line, for this I used UICollectionViewCell in witch I have some images no videos now I am images from gallery,I am taking the image using camera and I am recording the video,every time I will have any one out from the above and the out put i have add to the time line. For example, we take 3vc 1st vc is having collection view with some

How to fix UILabel text spacing?

给你一囗甜甜゛ 提交于 2019-12-02 01:20:02
问题 This code worked fine on iOS 12 and under and the issue occurs when running iOS 13. The goal is to remove the line height spacing to 0 so my labels have a reduced amount of space in between text. I have two labels inside a collection view cell and when I scroll the cells off the screen and then scroll back down the label text is now "cut off". This was not the case as I mentioned in previous versions of iOS. Any help fixing this would be amazing. Thanks ahead of time. This is my code:

UICollectionView reload data Issue

China☆狼群 提交于 2019-12-01 20:11:18
I have a problem with data reloading using UICollectionView . I have this array on the viewDidLoad to fill the UICollectionView. array = [[NSMutableArray alloc] init]; [array addObject:@"1"]; [array addObject:@"2"]; [array addObject:@"3"]; [array addObject:@"4"]; [array addObject:@"5"]; [array addObject:@"6"]; and the method: -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { NSString *cellIdentifier = @"Cell"; //cell = [[UICollectionViewCell alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; myCell *cell =

Should the contentView.translatesAutoResizingMaskToConstraints of a UICollectionViewCell subclass be set to `false`?

那年仲夏 提交于 2019-12-01 17:06:42
问题 TL;DR When trying to size UICollectionViewCells via auto layout, you can easily get auto layout warnings with even a simple example. Should we be setting contentView.translatesAutoResizingMaskToConstraints = false to get rid of them? I'm trying to create a UICollectionView with self sizing auto layout cells. In viewDidLoad: let layout = UICollectionViewFlowLayout() layout.estimatedItemSize = CGSize(width: 10, height: 10) collectionView.collectionViewLayout = layout My cell is very basic. It's

Should the contentView.translatesAutoResizingMaskToConstraints of a UICollectionViewCell subclass be set to `false`?

走远了吗. 提交于 2019-12-01 17:04:56
TL;DR When trying to size UICollectionViewCells via auto layout, you can easily get auto layout warnings with even a simple example. Should we be setting contentView.translatesAutoResizingMaskToConstraints = false to get rid of them? I'm trying to create a UICollectionView with self sizing auto layout cells . In viewDidLoad: let layout = UICollectionViewFlowLayout() layout.estimatedItemSize = CGSize(width: 10, height: 10) collectionView.collectionViewLayout = layout My cell is very basic. It's a single blue view with width and height 75 for testing purposes. The constraints are created by

Swift: Multiple UIButton in a IndexPath in a UICollectionViewCell programmatically, next addTarget does not click

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 15:31:09
I made multiple UIButton in a indexPath in a UICollectionViewCell programmatically. now i want to print "clicked add to favourite" but it is not printing anything after click UIButton . the UIButton does view everything except addTarget function not click. import UIKit //**UICollectionViewCell** class DescriptionCell: UICollectionViewCell, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout { override init(frame: CGRect) { super.init(frame: frame) setupCell() } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") }

how to create custom UICollectionViewCell

最后都变了- 提交于 2019-12-01 13:45:51
I have a UICollectionView and Im trying to set a label and an image in the collectionViewCell . Unfortunately I cant seem to get any labels to display or anything else for that matter. Here is my code: - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath]; UILabel *issue = [[UILabel alloc] initWithFrame:CGRectMake(0,10,cell.bounds.size.width,40)]; if(indexPath.item %2 == 0){ cell.backgroundColor=

Swift: Multiple UIButton in a IndexPath in a UICollectionViewCell programmatically, next addTarget does not click

主宰稳场 提交于 2019-12-01 13:36:24
问题 I made multiple UIButton in a indexPath in a UICollectionViewCell programmatically. now i want to print "clicked add to favourite" but it is not printing anything after click UIButton . the UIButton does view everything except addTarget function not click. import UIKit //**UICollectionViewCell** class DescriptionCell: UICollectionViewCell, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout { override init(frame: CGRect) { super.init(frame: frame)

set Dynamic width and height of collection view cell

瘦欲@ 提交于 2019-12-01 13:21:31
问题 Actually i want to set button dynamically and title of button appear Dynamic i have try this and got width of Dynamic content but am not setting cell width and height. - (void)viewDidLoad { [super viewDidLoad]; ContentArray = [[NSMutableArray alloc]init]; self.collectionview.delegate = self; self.collectionview.dataSource =self; self.collectionview.backgroundColor = [UIColor clearColor]; [ContentArray addObject:@"Planning"]; [ContentArray addObject:@"Resources"]; [ContentArray addObject:@