uicollectionviewcell

Getting button action : UICollectionView Cell

折月煮酒 提交于 2019-11-27 19:05:14
I have created a UICollectionViewCell by nib and added a button inside it and created a .h and .m files added the class to the nibs file's owner .then wrote a button action in the .m connected it via outlet. The collection view is populating fine ,but cannot get the buton action triggered. I think the delegate for collection cell is called. How can i get the button action? I had this problem as well. No subviews would receive touch events. While Scott K's workaround does work, I still felt something was wrong. So I took another look at my nib, and noticed that the original subview I used to

the behavior of the UICollectionViewFlowLayout is not defined, because the cell width is greater than collectionView width

懵懂的女人 提交于 2019-11-27 18:43:25
2015-08-18 16:07:51.523 Example[16070:269647] the behavior of the UICollectionViewFlowLayout is not defined because: 2015-08-18 16:07:51.523 Example[16070:269647] the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values. 2015-08-18 16:07:51.524 Example[16070:269647] The relevant UICollectionViewFlowLayout instance is , and it is attached to ; animations = { position=; bounds.origin=; bounds.size=; }; layer = ; contentOffset: {0, 0}; contentSize: {1024, 770}> collection view layout: . 2015

UICollectionView registerClass: forCellWithReuseIdentifier method breaks UICollectionView

孤者浪人 提交于 2019-11-27 18:22:25
What's the role of registerClass:forCellWithReuseIdentifier: method? According to Apple's developer documentation it's supposed to "Register a class for use in creating new collection view cells." When I try to use it my project I get a black collection view. When I delete it everything works fine. #define cellId @"cellId" #import "ViewController.h" #import "Cell.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UICollectionView *collectionView; @property(strong, nonatomic)NSMutableArray * photoArray; @end @implementation ViewController - (void)viewDidLoad { [super

UICollectionview Scrolling choppy when loading cells

六月ゝ 毕业季﹏ 提交于 2019-11-27 17:43:04
I have a gallery in my app utilizing a UICollectionView . The cells are approximately 70,70 size. I am using ALAssets from the ALAssetLibrary in the gallery which I have stored in a list. I am using the usual pattern for populating the cells: -(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { mycell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath]; mycell.imageView.image = [[UIImage imageWithCGImage:[alassetList objectAtIndex:indexpath.row] thumbnail]]; return mycell; } My

UICellView cell layout in swift

狂风中的少年 提交于 2019-11-27 16:20:45
I am trying to use a UICollectionView to create a grid which a user can set to be x cells by y cells (entered in text boxes), while still occupying the same width on the screen. I have been able to create a grid view which contains the correct number of cells, but these aren't in the correct layout yet, i.e. entering 5 by 7 will give 35 cells but not in a 5 cell by 7 cell layout. This is the code I have so far. MyCollectionViewCell.swift import UIKit class MyCollectionViewCell: UICollectionViewCell { @IBOutlet var cellLabel: UILabel! } CreateNewProject.swift class CreateNewProject :

Defining UICollectionViewCell with nib

我只是一个虾纸丫 提交于 2019-11-27 16:04:05
问题 If I understand correctly, the content of a UICollectionViewCell should go inside its contentView property and the background into backgroundView . Yet, when I drag a UICollectionViewCell to Interface Builder there is no mention of contentView or backgroundView . If I add subviews, those will have the whole cell as its parent, not contentView or backgroundView . What is the right way of defining a UICollectionViewCell with IB, then? 回答1: "If I add subviews, those will have the whole cell as

How to change space between cells in UICollectionView?

橙三吉。 提交于 2019-11-27 15:56:27
问题 I want to reduce the size between cells in row. Now it looks like: I'm trying this, for reduce the size between them: let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() layout.sectionInset = UIEdgeInsets(top: 20, left: 2, bottom: 10, right: 2) layout.minimumInteritemSpacing = 0 layout.minimumLineSpacing = 0 but it doesn't help me. What I do wrong? 回答1: //Objective c - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*

UICollectionViewCell content wrong size on first load

╄→尐↘猪︶ㄣ 提交于 2019-11-27 15:46:30
问题 I have a added a UICollectionView to my UIViewController and have made a custom cell for it. I set the size of the cell using the sizeForItemAtIndexPath method and set each cell to be UIScreen.mainScreen().bounds.width/2 in both height and width. So essentially, each cell is half the screen wide and this same length in height. I then have an UIImageView inside the cell with each edge pinned to its relative edge of the cell so that the image view fills the cell. I also have a UILabel that is

Copy Callout in UICollectionView

微笑、不失礼 提交于 2019-11-27 14:06:28
问题 I have a UICollectionView with UIImageView in each cell, now I want to add Copy Callout, like in Photos.app: I saw this method in the UICollectionViewDelegate: - (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath { return YES; } After few additional minutes of research I found UIMenuController Class, as I understood, I must to work with it to get the Menu, but anyway, I think that there must to be more simple way then creating

UICollectionView, simply fit cell to width?

寵の児 提交于 2019-11-27 12:46:55
问题 Here's a simple UICollectionView in yellow The red arrow sets the width of the cell. (TBC: clicking on the pink cell: for 'size' select 'Default', then what you set at the red arrow becomes the size of the cell.) Example, for an upright iPhone set width to 320. But this seems crazy ... surely I can set the cell width based on the width of the UICollectionView ? There's no problem autosizing the view itself .. That works fine. But it seems crazy that I can't set the width of the CELL to be