uicollectionviewcell

Manipulate IB Outlets in awakeFromNib for UICollectionViewCell even if not using custom XIB?

ぃ、小莉子 提交于 2019-12-12 00:35:18
问题 The code below is used to manipulate and configure IB Outlets of a subclassed UICollectionViewCell. The IB outlets in the class, however, are not yet connected at this stage. Other SO posts like this one suggest using awakeFromNib to manipulate the IB outlets, but in all the answers, the problem deals with a custom XIB. However, this subclass doesn't use a custom XIB. Is it still right to use awakeFromNib to configure the IB outlets even if no custom XIB is used? override init(frame: CGRect)

Uicollectionview controller issue

人走茶凉 提交于 2019-12-11 20:32:30
问题 App crash and give following error message Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UICollectionViewController loadView] loaded the "RecipeCollectionViewController" nib but didn't get a UICollectionView. 回答1: Try setting a breakpoint on: [self.collectionView registerClass:[ImageCell class] forCellWithReuseIdentifier:@"MyCell"]; i would guess your loadView (did you mean viewDidLoad?) method is not being called, so the class is never registered

focus on UITextField inside a UICollectionViewCell

笑着哭i 提交于 2019-12-11 19:51:30
问题 I have created a custom UICollectionViewCell that contains a UITextField inside of it which is only accessible when the cell is selected. The CollectionView has multi select enabled and the problem is that when trying to select the UITextField to type in it, the cell is deselected instead of giving the TextField focus. How do I allow focus on the UITextField inside of the CollectionViewCell without causing the cell to be deselected? Note: I've also tried adding buttons to the cell template

Why UICollectionView with UICollectionViewFlowLayout not show cells, but ask for size?

半城伤御伤魂 提交于 2019-12-11 18:24:07
问题 Why collectionview with flow layout sometimes not showing cells, but delegate ask for size, and section items count and responder give correct information. Here example, trouble with 6 section 2015-04-08 04:43:59.020 ASKED SECTION:0 ITEMS:0 2015-04-08 04:43:59.023 RETUR SECTION:0 ITEMS:1 2015-04-08 04:43:59.023 ASKED SECTION:1 ITEMS:0 2015-04-08 04:43:59.024 RETUR SECTION:1 ITEMS:1 2015-04-08 04:43:59.024 ASKED SECTION:2 ITEMS:0 2015-04-08 04:43:59.024 RETUR SECTION:2 ITEMS:1 2015-04-08 04:43

Custom UICollectionViewCell Subview Layout Issue

坚强是说给别人听的谎言 提交于 2019-12-11 18:03:57
问题 I have a custom UICollectionViewCell class that sets the background view of the cell to a downloaded image and also a UILabel added to it that sits neatly at the bottom of the cell and is slightly transparent (this label is the title of the image). It looks great in portrait but when I rotate my device to landscape the UILabel stays in its position while the custom cell resizes itself to better fit the screen. I have my UILabel fully constrained to the cell so I don't know why it isn't

How to get the frame size of a UIImageView in a UICollectionView cell

狂风中的少年 提交于 2019-12-11 17:42:59
问题 I'm trying to get the frame size of a UIImageView inside a UICollectionViewCell . I have currently tried to achieve this using thumbnailImageView.frame.size but this returns (0.0, 0.0) no matter where I call this method from. The reason I want to do this is to round the edges of the image inside the image view, but as I am using .scaleAspectFit I need to know the frame size and image size to correctly round the corners. Below is the cell class: class SomeCollectionViewCell:

Cell Layout refresh after deleting one cell in UICollectionView

五迷三道 提交于 2019-12-11 17:41:43
问题 I created a UICollectionView with dynamic resizing of cell height. I am resizing the cell like this: func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let approximatedwidthoftextview = view.frame.width - 70 let size = CGSize(width: approximatedwidthoftextview, height: 1000) let attributes = [NSAttributedStringKey.font: UIFont(name: "Avenir Next", size: 18)] let estimatedFrame = NSString

UICollectionView horizontal paging presenting 3 cells per row on first page only

你。 提交于 2019-12-11 17:37:31
问题 I have a UICollectionView that I have implemented to scroll horizontally but for some reason when I scroll through there are only 3 cells that are presented (when there should be 9) class BusinessPhotosViewController: UICollectionViewController ,UICollectionViewDelegateFlowLayout{ let cellId = "photos" override func viewDidLoad() { super.viewDidLoad() if let layout = collectionView?.collectionViewLayout as? UICollectionViewFlowLayout { layout.scrollDirection = .horizontal layout

Resize CollectionView Cell during runtime without reloading

核能气质少年 提交于 2019-12-11 17:17:01
问题 For my app, it is necessary to resize a specific collectionview cell during runtime in order to fit the content size - just like .sizeToFit() but for collection view cells However, so far I only found solutions on how to dynamically size each collection view cell on startup. Is there any way to resize a collection view cell (in a smooth way) to fit the content size without reloading the whole collection view and losing all entered data? I am using AutoLayout and no storyboards - a programatic

How to make UICollectionViewCells have rounded corners and drop shadows?

旧时模样 提交于 2019-12-11 16:44:21
问题 I've seen some other answers to similar questions, but none of the solutions have worked for me, even with some tweaking. As the title suggests, I would like my UICollectionViewCell s to have rounded corners and drop shadows (or shadows on all sides except the top). What I have done so far is to add two views to my UICollectionViewCell - mainView , which displays the cell's necessary content and has rounded corners, and shadowView , which has the shadow. Neither view is a subview of the other