uicollectionviewcell

Issue with nested UICollectionViews

夙愿已清 提交于 2019-12-06 13:14:01
I have 2 nested UICollectionViews. The delegate for the outer collection view is the main view controller, and the inner collection views delegate is the UICollectionCell of the outer collection view. The outer collection view has only a label and the inner collection view in it - normally there would be seven of these, the inner collection view should contain 3 or 4 cells (containing 3 labels). The problem is that the inner collection view only seems to get updated twice (for the first 2 sets of data in the outer views) after that they repeat. Here is the cellForItemAtIndexPath for the outer

How do I get a UIButton press to work in a UICollectionViewCell in Swift?

别说谁变了你拦得住时间么 提交于 2019-12-06 12:58:46
So this is a tvOS project in Swift. I have a custom UICollectionViewCell with a button as one of its subviews. I add a target to the button to allow it to interpret clicks. Here's a simplified version of the relevant code class CustomCell: UICollectionViewCell { var button:UIButton! override init(frame: CGRect) { super.init(frame: frame) button = UIButton(...) // Button is initialized with a frame button.userInteractionEnabled = true button.enabled = true button.addTarget(self, action: "pressed:", forControlEvents: .PrimaryActionTriggered) contentView.addSubview(button) } func pressed(sender:

uicollectionview Loads wierdly

自古美人都是妖i 提交于 2019-12-06 11:31:48
问题 I created a collection view with custom collection cell.set with flowlayout as UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; [flowLayout setItemSize:CGSizeMake(250, 480)]; [flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal]; [self.templateCollectionView setCollectionViewLayout:flowLayout]; I set it horizontal but still a cell is misplaced in figure see att mmp misplaced & it will back in its correct position if we scroll and load it

iOS: Image view aspect fit with corner radius

喜夏-厌秋 提交于 2019-12-06 08:00:57
I want to set corner radius with content mode as aspect fit using following code: cell.imgvAlbum.contentMode = UIViewContentModeScaleAspectFit; cell.imgvAlbum.clipsToBounds = YES; cell.imgvAlbum.layer.cornerRadius = 5.0f; but i am getting output only for content mode as aspect fit. I have also tried for: cell.imgvAlbum.layer.masksToBounds = YES; What to do for corner radius? Please suggest me some solution. Thanks in advance. Use below method to get a Rounded corner image with the specified radius for rounded corner, apply all your above properties as UIViewContentModeScaleAspectFit , clip to

UICollectionViewCell dynamic height w/two dynamic labels & auto layout

我是研究僧i 提交于 2019-12-06 06:31:41
问题 I have a UICollectionViewCell subclass that's setup with a prototype cell and constraints (every view is connected both vertically and horizontally). I have two labels that can vary in size, they can be either one or two lines. To that end I have set two height constraints on each label, one with a greater than or equal (16 or 20 depending on the label) and a less than or equal (32 or 40 depending on the label). The number of lines on the labels are set to 0. (Though I have tried a variety of

Label text in UICollectionViewCell not updating

删除回忆录丶 提交于 2019-12-06 06:00:51
I'm trying to change the text of a UILabel in a UICollectionViewCell after the UICollectionViewCell has loaded, when tapping a button . But the label doesn't update on the screen. The console shows that the text property of the label is updated, but it seems the label isn't redrawn with the new text. Is this a known problem with UICollectionViewCells ? Some kind of caching issue, perhaps? Do I need to reload the cell, or the entire collection view for the update to show? Because the cell is already loaded, no change in cell will happen until it's reloaded, so you can either reload the entire

Adding multiple buttons + receiving touchUpInside event inside UICollectionViewCell SWIFT programmatically

∥☆過路亽.° 提交于 2019-12-06 05:50:16
I am trying to build a CollectionView for a list all programmatically in Swift without using Storyboard. I was able to add a tap gesture event to the cell. However, When I added a set of buttons to the UICollectionViewCell's contentView, the buttons do not receive any touch events. Inside Controller let sampleCollectionView = UICollectionView(frame: (..), collectionViewLayout: layout) //Register the UICollectionViewCell inside UICollectionView sampleCollectionView.registerClass(sampleCollectionViewCell.self, forCellWithReuseIdentifier: "sampleCell") //Add Tap Gesture event to the cell area let

UICollectionCell to call method in CollectionViewController

孤人 提交于 2019-12-06 05:41:16
问题 I have a standard view controller that contains a collection view. I am populating the collection view with custom cells created from a custom subclass of UICollectionViewCell . What is the best practice of calling a method in the collection view class from within the collection view cell class Why doesnt the following init get called in my collection view cell class, I thought this would be called when the collectionView class creates my cells. (id)initWithFrame:(CGRect)frame The reason I

nil label for custom UICollectionCell

流过昼夜 提交于 2019-12-06 05:22:10
EDIT : seems like same question as this I made collection view with custom layout and cell but my cell's positions were a little off so I decided to number them so that I could debug it easier. I followed this guy's answer to number my cell using labels. Somehow myLabel was nil and caused my app to crash. I believe I have connected the outlets correctly but maybe someone could provide a list for me to check if I am doing anything wrong. ViewController import UIKit class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate { @IBOutlet var gridView:

How to resize UICollectionViewCell in iPhone 6 and 6 Plus using autolayout

戏子无情 提交于 2019-12-06 05:17:23
问题 I'm working in a iOS project where i use collectionView using Autolayout and SizeClasses. custom UICollectionViewCell xib is used. Where i reuse custom cell in collectionView presenting two cells like below image in iPhone 5s. problem is while running the same project in iPhone 6 and 6 Plus, the cells are not resizing there is space between cells you can see it below. which is resizing in xib when the size of cell is increased and select update frames but not resizing for iPhone 6. Answers