uicollectionviewcell

How to display CollectionViewCell in center in swift 4

怎甘沉沦 提交于 2019-12-01 12:38:20
Collectionview cell has a two item in one row, But Collectionview cell doesn't center in my design. How can I display the collectionViewCell in center alignment? I want to display like the following image I am trying many times, can't display the center of CollectionView. Please Help me! Working code Swift 4 You need to use UICollectionViewDelegateFlowLayout method like this class CardListViewController:UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout{ // UICollectionViewDelegateFlowLayout Delegate method func collectionView(_ collectionView:

UICollectionView Flow layout no fixed row height

我的未来我决定 提交于 2019-12-01 11:17:07
问题 How to modify the flow layout, so that there is the same vertical spacing between the smaller and larger cells (eg. there is no fixed row height / the row height is not fixed to the maximal size)? I want to look it like this 回答1: The solution was using UICollectionViewWaterfallLayout Follow the setup from the website, and you can setup it like this - (void)viewDidLoad { [super viewDidLoad]; UICollectionViewWaterfallLayout * layout = (UICollectionViewWaterfallLayout *)self.collectionView

How to display CollectionViewCell in center in swift 4

允我心安 提交于 2019-12-01 11:09:16
问题 Collectionview cell has a two item in one row, But Collectionview cell doesn't center in my design. How can I display the collectionViewCell in center alignment? I want to display like the following image I am trying many times, can't display the center of CollectionView. Please Help me! 回答1: Working code Swift 4 You need to use UICollectionViewDelegateFlowLayout method like this class CardListViewController:UICollectionViewDelegate,UICollectionViewDataSource

how to create custom UICollectionViewCell

牧云@^-^@ 提交于 2019-12-01 10:59:50
问题 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]

Swift How to get the centre cell in a collectionView and resize it when scrolling?

三世轮回 提交于 2019-12-01 09:03:58
I have a horizontal collectionView and i would like to manage that when scrolling it, the centre cell becomes larger. So, each time a cell is the center cell it will be larger than the others. Check the image beneath. Can anyone help me with the best way to do this? Thanks in advance! My code so far: import UIKit class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate { @IBOutlet var horizontalCollectionView: UICollectionView! @IBOutlet var verticalCollectionView: UICollectionView! var horizontal = ["1","2","3","4","5","6","7","8","9","10","1","2","3","4",

Add Facebook Shimmer on multiple UIViews

旧时模样 提交于 2019-12-01 09:03:46
I am trying to add Facebook Shimmer on UICollectionViewCell which has multiple UIViews. For one UIView , it's working fine with below code: let shimmeringView = FBShimmeringView(frame: imageView.frame) shimmeringView.contentView = imageView backgroundView.addSubview(shimmeringView) shimmeringView.isShimmering = true Where backgroundView is the view in which I have all the subviews such as imageView , labelView and others. While I am trying to add multiple views then first view is getting correct frame but other views' widths are becoming zero. I'm adding this code inside collectionView(_

UICollectionView Cell with Image, change Background with click

六月ゝ 毕业季﹏ 提交于 2019-12-01 08:23:23
I have a UICollectionView with Custom CollectionView Cells . On each Cell there is a Image on it, which is as big as the whole Cell. Now i want to highlight the Cell when the User touches the Cell. First i tried it with the following delegate Methods : - (void)collectionView:(UICollectionView *)collectionView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewCell* cell = [self.collectionView cellForItemAtIndexPath:indexPath]; cell.contentView.backgroundColor = [UIColor redColor]; } - (void)collectionView:(UICollectionView *)collectionView didUnhighlightItemAtIndexPath:

How to present an AlertView from a UICollectionViewCell

扶醉桌前 提交于 2019-12-01 08:06:41
I am using a UICollectionView with a Map in the header. I want to handle Core Location errors. I have 3 error types and for two of them I want to present a UIAlertView . But I am getting an error, because UICollectionViewCell doesn't have a member called presentViewController . func locationUnknown() { var alert = UIAlertController(title: "Location Unknown", message: "Please try again later.", preferredStyle: UIAlertControllerStyle.Alert) let alertAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: { (action: UIAlertAction!) -> Void in }) alert.addAction(alertAction

UICollectionView - order cells horizontally

只谈情不闲聊 提交于 2019-12-01 07:33:19
So basically my problem is that my uicollectionview's cells are ordered from top to bottom, rather than from left to right. This is what it looks like - [1][4][7] [2][5][8] [3][6][9] This is what i want - [1][2][3] [4][5][6] [7][8][9] Another problem is when i scroll horizontally instead of moving the page a full 320points. It only moves enough to fit the next cell in the view. this is what it looks like - [2][3][10] [5][6][ ] [8][9][ ] this is what i want - [10][ ][ ] [ ][ ][ ] [ ][ ][ ] I was hoping rendering it horizontally would fix it though. I'm still new to ios so please show me how to

How to present an AlertView from a UICollectionViewCell

≡放荡痞女 提交于 2019-12-01 07:04:36
问题 I am using a UICollectionView with a Map in the header. I want to handle Core Location errors. I have 3 error types and for two of them I want to present a UIAlertView . But I am getting an error, because UICollectionViewCell doesn't have a member called presentViewController . func locationUnknown() { var alert = UIAlertController(title: "Location Unknown", message: "Please try again later.", preferredStyle: UIAlertControllerStyle.Alert) let alertAction = UIAlertAction(title: "OK", style: