uicollectionviewcell

Could not cast value of type 'UICollectionViewCell'

风格不统一 提交于 2019-12-03 06:14:01
问题 I use a custom CollectionViewCell in my Storyboard. When I start the app I get this message: Could not cast value of type 'UICollectionViewCell' to TestProject.CollectionViewCell. 回答1: The template for a CollectionViewController in Xcode comes with this line of code in viewDidLoad, which changes the specification in your storyboard. // Register cell classes self.collectionView!.register(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier) Simply delete that line. In older

Fit given number of cells in uicollectionview per row

痴心易碎 提交于 2019-12-03 06:06:45
问题 I have a collection view and I would like to have let's say 4 cells per row. I know that to accomplish this all I need to do is divide collectionview.frame.size.width by 4. This is easy. However, what I can not figure out, is how to take into consideration the insets at the side of the collection view and the spacing between the cells. I have 10 pixel insets on the left and right of the collection view, as well as there is a 10 pixel spacing between the cells. How can I calculate the required

UICollectionViewCell register class fails, but register nib works

会有一股神秘感。 提交于 2019-12-03 05:49:02
Creating a custom UICollectionViewCell for my UICollectionViewController , it works by registering the nib; however, fails to register by class. Using registerClass() - fails Registering by class seems correct - it builds, but throws an exception at runtime unwrapping optional elements from the UIView. Without referencing outlets, it runs; however, no cells appear within the collection view. collectionView?.registerClass(MyCollectionViewCell.self, forCellWithReuseIdentifier: "myCell") Clearly the view is not loaded; however, I'd think setting the custom class of the cell would provide

How can I customize the selection state of my UICollectionViewCell subclass?

孤人 提交于 2019-12-03 05:38:38
问题 I have a custom UICollectionViewCell subclass that overwrites initWithFrame: and layoutSubviews to setup its views. However, I'm now trying to do two things which I'm having trouble with. 1) I'm trying to customize the state of the UICollectionViewCell upon selection. For example, I want to change one of the images in an UIImageView in the UICollectionViewCell . 2) I want to animate (light bounce) the UIImage in the UICollectionViewCell . Can anyone point me in the right direction? - (void

UICollectionViewCell dynamic sizing for 4.4 and 5.5 inch

会有一股神秘感。 提交于 2019-12-03 05:16:24
I have UICollectionView with cells in the storyboard. The size of each cell is set to 145x145. They look good on the iPhone 4 - 5s, but the size doesn't increase proportionally on the iPhone 6 and 6+. Rather than manually setting a different cell size for each device, how can I do it dynamically? See examples here: iPhone 5S: http://prntscr.com/55vy7q , iPhone 6: http://prntscr.com/55vyy2 If you want your cells to adjust their width, you'll need to calculate the flow layout's itemSize based on the view width. If all your cells will be the same size , you can set the flow layout's itemSize

UICollectionView like iOS Home Screen [closed]

纵然是瞬间 提交于 2019-12-03 04:36:10
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I wanna make an UICollectionView like iOS Home Screen. I found several (and good) samples like: http://mobile.tutsplus.com/tutorials/iphone/uicollectionview-layouts/ http://www.cocoacontrols.com/platforms/ios/controls/sespringboard http://www.cocoacontrols.com/platforms/ios/controls/aqgridview http://www

Perform Segue from UICollectionViewCell Button different from Cell Click

余生颓废 提交于 2019-12-03 03:58:41
I have a UICollectionViewCell , with a UIButton . And I have two different actions. The first one, when the user presses the cell, it will segue to another view with didSelectITemAt ; the second one, when the users presses the UIButton inside the cell. My problem is that on Swift Code of MyCollectionViewCell , I cant perform a segue, When I write the Code: self.performSegue(withIdentifier: "toStoreFromMyDiscounts", sender: nil) it says the error: Value of Type MyCollectionViewCell has no member performSegue. I also cannot write prepareForSegue , it doesn't auto complete. How can I create a

is possible to zoom in/out a UIImageView in custom cell of a UICollectionView only when pinch the cell's imageView?

混江龙づ霸主 提交于 2019-12-03 00:51:10
I have a CollectionView that have one custom cell. I want to zoom in/out imageView in cell, so i add pinch gesture at CollectionView.m when i add gesture to self.collectionView, like this: [self.collectionView addGestureRecognizer:pinchGesture]; it works! my cell.imageView can zoom in/out, but when i pinch other place(not in cell's imageView, my cell.imageView still zoom in/out with the gesture, I want the cell.imageView zoom in/out just when user pinch the cell.imageView, so i try to add gesture use this code: [cell.imageView addGestureRecognizer:pinchGesture]; but unfortunately it doesn't

How to scroll UICollectionViewCell programmatically in IOS?

自闭症网瘾萝莉.ら 提交于 2019-12-03 00:48:45
I have a vertical UICollectionView with each cell taking up the entire self.view.frame I can easily swipe upwards to page to the next cell, but I would like to do the same thing with the press of a button. I've tried using: - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated And: - (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated They work but they temporarily "White-Out" the currentCell to present the nextCell, while the swiping shows both cells during the transition. Ideally I would like to use: - (void)scrollToItemAtIndexPath:(NSIndexPath *)indexPath

How to refresh UICollectionViewCell in iOS 7?

蹲街弑〆低调 提交于 2019-12-03 00:02:32
I am trying to develop my app in Xcode 5 and debug it under iOS 7 environment. I have a customized UICollectionViewLayoutAttributes. I plan to do something after long pressing on UICollectionViewCell, so I override the method in UICollectionViewCell.m - (void)applyLayoutAttributes:(MyUICollectionViewLayoutAttributes *)layoutAttributes { [super applyLayoutAttributes:layoutAttributes]; if ([(MyUICollectionViewLayoutAttributes *)layoutAttributes isActived]) { [self startShaking]; } else { [self stopShaking]; } } In iOS 6 or below, - applyLayoutAttributes: is called after I call the statements