uicollectionview

Getting the screen location of a cell from a UICollectionView

限于喜欢 提交于 2019-12-20 08:27:02
问题 This isn't so much a question as an explanation of how to solve this problem. The first thing to realize is that the UICollectionView does inherit from a UIScrollView - so doing a standard lookup with a scroll view's content is the best solution. Here's the problem I was addressing: I had a UICollectionView that had differing items in each cell - along with differing types of cells. I need the selection of a cell to cause an effect of the image in the cell to appear to expand and take over

UICollectionViewCell one of the section from UICollectionView Cell Repeating same cell for multiple times

久未见 提交于 2019-12-20 07:02:25
问题 I have an old project done by a developer some times ago.. This particular project has 3 collection views such as collectionAnnouncments, collectionNews and collectionBulletin. The first collectionview collectionAnnouncments is loading a same cell 10 times. But other two sections loading the cell correctly one time as per the response count. I don't have any idea up to now for this problem. I tried some solutions from the google but I couldn't sorted because of the bad UI and Code

problem with images loading on top of already set images swift 4

痞子三分冷 提交于 2019-12-20 06:24:03
问题 I'm having an issue in my cellForItemAtIndexPath where I am setting an image to my cell's UIButton but every time I scroll the collectionView's cells, it's placing the image on top of the already set image again and again. I can tell because the shadow of the image is getting thicker and thicker. I'm pulling the images from an array that I created of image literals in that swift file and the correct images are loading so there's no problem there. I'm sure this is a simple fix for most but I

Landscape orientation for Collection View in Swift

橙三吉。 提交于 2019-12-20 06:11:17
问题 I am encountering a problem on landscape orientation for my collection view cell. When the app is in portrait it gives me the correct number of cell per row which is 2. But when I rotate my app to landscape it display 1 cell per row. Here's the screen of what I got: Portrait: Landscape: Here's my code for adding the size of the cell: func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) ->

Collection View inside Table does not load immediately in swift 3

╄→гoц情女王★ 提交于 2019-12-20 06:10:06
问题 I add one table view in Home View Controller . Inside table view, I add Collection View. An Image inside collection view at first time running the app. Then, goes to other links and come back to Home but image in the collection view does not show immediately until it scrolls at this second time. After pulling the view several times, then Image appears. In " Collection.swift " , In ViewDidLoad() , DispatchQueue.main.async { self.tableView.reloadData() } I also add in viewWillLayoutSubviews()

View height constraints are not set correctly as I scroll UICollectionView up and down

懵懂的女人 提交于 2019-12-20 05:49:13
问题 I'm trying to decide view heights based on a model property, but as UICollectionView is scrolled up and down, incorrect heights are assigned to visible cells. It seems that setting a HeightAnchor in GetCell (i.e. cellForItemAtIndexPath ) does not work. How can I make this work? using CoreGraphics; using Foundation; using System; using System.Collections.Generic; using UIKit; namespace App2 { public partial class ViewController : UIViewController { private UICollectionView _collectionView;

UICollectionviewcell change background

家住魔仙堡 提交于 2019-12-20 04:51:53
问题 How to change the background in the cell if I know the section number and the item number? The code below shows how I tried to do it. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { CalendarCollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath]; cell.titleLabel.text = [NSString stringWithFormat:@"%i",indexPath.item-dayStart+2]; if (indexPath.section

iOS 7: Keeping the displayed items in the viewing area after rotation of UICollectionView

血红的双手。 提交于 2019-12-20 04:37:31
问题 I'm using a UICollectionView with horizontal scrolling (Layout = UICollectionViewFlowLayout ). After rotation I adapt the content offset so that the same items are displayed before the rotation. On rotation the width of the items are changed, because there are always seven items on screen. My current approach does work for iOS 8, but not for iOS 7. On iOS 7 layoutAttributesForItemAtIndexPath always returns the same X position regardless of the orientation. So it seems that some frame is not

UILabel with Tap Gesture Recognizer not working

筅森魡賤 提交于 2019-12-20 04:26:14
问题 I have designed a UICollectionViewCell using XIB and in that custom cell I have an UILabel whose user interaction I have enabled. In my viewcontroller when I am designing the cell , Here is my code. UITapGestureRecognizer *buyNowTapped = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(buyNowClicked:)]; buyNowTapped.numberOfTapsRequired = 1.0; cell.buy.tag = indexPath.row; cell.buy.userInteractionEnabled = YES; [cell.buy addGestureRecognizer:buyNowTapped]; -(void

Reloading collection view inside a table view cell happens after all cells in table view have been loaded

◇◆丶佛笑我妖孽 提交于 2019-12-20 04:23:22
问题 I am trying to implement a collection view inside each table view cell in a table view, but am having trouble getting the collection view to reload at the right time. It looks like the collection view reloads itself after all the table view cells have been loaded, not each time a new cell is dequeued to the table view as I'm trying to make it do. func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView