uicollectionviewcell

Subclassing UICollectionViewCell leads to never being selected

无人久伴 提交于 2019-12-11 02:15:47
问题 I've tried subclassing a UICollectionViewCell and loading from a nib file: - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { NSArray *arrayOfViews = [[NSBundle mainBundle] loadNibNamed:@"DatasetCell" owner:self options:nil]; if ([arrayOfViews count] < 1) { return nil; } if (![[arrayOfViews objectAtIndex:0] isKindOfClass:[UICollectionViewCell class]]) { return nil; } self = [arrayOfViews objectAtIndex:0]; UIView *view = [UIView new]; view.frame = self.frame;

Trouble accessing Image from instance of UICollectionViewCell

穿精又带淫゛_ 提交于 2019-12-10 23:23:30
问题 I'm following this tutorial with some modifications for my project: http://www.appcoda.com/ios-programming-uicollectionview-tutorial/ I'm trying to get the instance of UIImageView that IB creates for me. Here is a screenshot of my IB: I have a custom class called FeedViewCell that is to contain an UIImageView. Here is the cellForItemAtIndexPath code: - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ static NSString

UICollectionViewCell alpha value on Rotate

无人久伴 提交于 2019-12-10 21:06:19
问题 I have a UICollectionView with a custom UICollectionViewCell . I set the alpha property in the UICollectionViewCell to 0.0f for a speific task which all works as expected. However, when I rotate the view to landscape the cell's alpha resets itself to 1.0 . I've played around with this and the collection view holds the state of selected cells and removed cells etc. but not the alpha value of the cell. I have tried to re-set the alpha values of the changed cells on

Adjust UICollectionViewCell to fit content

久未见 提交于 2019-12-10 20:21:36
问题 I have a label that is set to resize to its content. I want the UICollectionViewCell to do the same. I cannot find anyway to implement that. A picture describing my current arrangement can be found below: 回答1: I think you'll want to implement the UICollectionViewDelegateFlowLayout method collectionView:layout:sizeForItemAtIndexPath: to adjust the size of each collection item based on the contents. Here's a tutorial on Collection Views that covers this specific topic. 回答2: Use "Autolayout" in

UICollectionView Enable deselecting cells while allowsMultipleSelection is disabled

喜欢而已 提交于 2019-12-10 17:45:51
问题 When collectionView.allowsMultipleSelection = YES; I can deselect cells that were selected. when collectionView.allowsMultipleSelection = NO; I cannot deselect cells that were selected. Is there anyway I can only set collectionView.allowsMultipleSelection = NO; and be able to deselect the selected cell? so there would either be one selected or none selected. I understand you can implement your own selection with a tap gesture then calling setSelected when gesture is detected. But I am looking

How to initialize popover view from UICollectionViewCell in IOS

最后都变了- 提交于 2019-12-10 15:44:26
问题 I've been tracking along with an iPad app using storyboards, and I've been stuck on this for days. How can I initiate a popover segue by selecting a cell in a collection view? The main problem is getting past the error that the popover must be anchored to a view. The approach seems to be putting a dummy popoverAnchorButton (hidden, disabled) in the view, create a segue from it to the popover view in the storyboard, position it in didSelectItemAtIndexPath , and then [self performSegue] . Code

Is it possible to use IBDesignable with UICollectionViewCells and live render them in storyboard?

假如想象 提交于 2019-12-10 13:56:08
问题 I know how to use @IBDesignable with custom views. but is it possible to use IBDesignable for cells and render them in storyboard? for example: i have a collectionViewController in storyboard, and added a uiCollectionCell and specified class as my customCellClass. p.s: i know for using Xibs in collecionViews and tableViews we have to call method registerNib:forReuseIdentifer in code (and i am doing it). just wondered, is it possible to see it's rendered view in storyboard or not. p.s2: i

Create UICollectionViewCell programmatically without nib or storyboard

爱⌒轻易说出口 提交于 2019-12-10 13:37:19
问题 Is there a way to create UICollectionViewCell without using existing cell identifier and existing nib file in cellForItemAtIndexPath method? 回答1: Its not necessary to use Storyboard/Xib for the CollectionViewCell. You can even create it programmatically. Subclass UICollectionViewCell and write up the code for the cell. Then in CollectionView controller class you have to register you custom cell class with the collectionView [self.collectionView registerClass:[CustomCollectionViewCell class]

Swipe Left/Right on collectionView not called while scrolling vertically

安稳与你 提交于 2019-12-10 13:15:20
问题 I have a collectionView with vertical scrolling, covering whole screen on the device (i.e fullscreen). I have register the Swipe Left and Right gestures for my collectionView . //------------right swipe gestures in collectionView--------------// let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(ViewController.rightSwiped)) swipeRight.direction = UISwipeGestureRecognizerDirection.Right self.collectionView.addGestureRecognizer(swipeRight) //-----------left swipe gestures

How to use collectionview flow layout to get correct view?

戏子无情 提交于 2019-12-10 12:00:58
问题 I am using this code to get correct type but not getting the view what i want can any one tell me where am i wrong override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) screenSize = UIScreen.main.bounds screenWidth = screenSize.width screenHeight = screenSize.height videosCollectionView.delegate = self videosCollectionView.dataSource = self } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return 4 } func