uicollectionview

Collection View Cell does not display image in image view

非 Y 不嫁゛ 提交于 2020-01-05 13:56:12
问题 I am trying to create a simple gallery for an iOS application. I'm working with a UICollectionView inside of a ViewController. Everything seems to be working fine, but I can't get the image I'm trying to use to display inside of the collection view cell. I will just dump some code here, I have been desperate to find a solution but nothing seems to work. This is the gallery.m file: -(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView; { //just a random value for

How to get the selected CollectionViewCell in the UICollectionView?

╄→гoц情女王★ 提交于 2020-01-05 12:14:33
问题 I am new for IOS development , and I try to use UIcollectionView to show the photo without using storyboard . I create a xib file call AITFileCell_grid.xib , and add a Collection View Cell . I also create another xib file and add the Collection View for loading Collection View Cell . I want to selected multiple file and delete them by delete button . But I can not get the cell when I click the delete button by following code. if(self.collectionView.indexPathsForSelectedItems > 0){ NSLog(@

UICollectionViewCell is square, but image is rectangle

回眸只為那壹抹淺笑 提交于 2020-01-05 08:58:28
问题 I am using UICollectionView where cell's are almost square, but original image is rectangle. Therefore, when I display image as follows, it is getting cut. Is there a way to handle this issue? I am currently working on Objective-C but I am to see Swift solution as well. cell.productImage content mode is Aspect Fill cell.productImage.image = [cell.productImage.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 回答1: Please add this line to your code. cell.productImage.contentMode

Auto Layout Collection view according to various screen sizes

大城市里の小女人 提交于 2020-01-05 05:28:05
问题 I'm using a collection view inside a normal view controller using the collection view delegate and data source. I'm using the sizeForItemAtIndexPath but it doesn't resize the cell. let screenSize: CGRect = UIScreen.main.bounds func collectionView(_collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { return CGSize(width: screenSize.width / 3, height: screenSize.width / 3) } The collection view is

UICollectionView reverse Layout

耗尽温柔 提交于 2020-01-05 04:38:11
问题 I've got a problem, i want make CollectionView like a 'chat'. Than i should reverse Layout of UICollectionView . Can i configure layout that contentOffset = (0; 0) will be on bottom UICollectionView (and important i can't transform CollectionView)? Like -> constenOffset = (0; 1000) (for example) | ... | | 2 | | 1 | | 0 | -> constentOffset = (0; 0) Also I tried to rotate UITableView but in this case reloadSection animation does not satisfy me. 回答1: UICollectionView with a reversed flow layout.

UIRefreshControl( pull left to right refresh ) concept in UICollectionView horizontally

微笑、不失礼 提交于 2020-01-05 02:51:27
问题 I have a custom horizontal collection view that has 1 row and I want to add pull to refresh functionality which, by default, appears above my row of cells. I would like the user to be able to pull the collection view from left to right to activate the UIRefreshControl. Any ideas? 回答1: For this you need to implement the UIScrollViewDelegate method - (void)scrollViewDidScroll:(UIScrollView *)scrollView { CGPoint offset = scrollView.contentOffset; CGRect bounds = scrollView.bounds; CGSize size =

UICollectionView - Change Location of Header

余生长醉 提交于 2020-01-04 14:07:05
问题 I have a UICollectionView that is using UICollectionViewFlowLayout to print a grid of cells to the screen. I configured the layout to flow horizontally & now I need to add a header to each section. My main issue is with the location of the header which is to the left of the section while I want it to be on top of the section (similar to what it would be if the layout was configured to flow vertically). Is there a way to do that short of creating my own UICollectionViewFlowLayout subclass? and

Swift: How to continuously adapt a UICollectionViewCell height to a UITextView while writing in it?

微笑、不失礼 提交于 2020-01-04 09:06:16
问题 Good afternoon. I've struggled with this "feature" for my iOS app for some hours now and I'm in need of some help. Question: How should I implement so that when a user types in the UITextView increases in size (only the bottom margin) and the cell increases its height to fit the UITextView dynamically meanwhile? I can't figure out how to tackle it. Research: After some searching I came upon Dynamically change cell's height while typing text, and reload the containing tableview for resize as

UICollectionView - Image is getting set randomly

白昼怎懂夜的黑 提交于 2020-01-04 06:36:07
问题 I am using collectionView in my App. I am setting image for the cell backgroundView in didSelect delegate. But When i select one cell indexPath the image is getting set for 3 cell indexPath. When i scroll the collectionView the images are getting changed randomly? Please Help me. thanks in advance. - (void)viewDidLoad { [super viewDidLoad]; [collection registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:uio]; } - (NSInteger)collectionView:(UICollectionView *)collectionView

Exchange position of cells by gesture

随声附和 提交于 2020-01-04 01:53:16
问题 I have UICollectionView in which I have a prototype cell and UIImageView in it.I am displaying random images in UICollectionView . Now I want to exchange position of UIImageView by swiping it to near cell.I have tried swipe gesture and long press gesture.Code is given below which I have done: - (IBAction)LongPress:(UILongPressGestureRecognizer *)sender { if (sender.state != UIGestureRecognizerStateEnded) { return; } CGPoint p = [sender locationInView:self.collectionView]; NSIndexPath