uicollectionview

passing info from collectionView to gameScene

雨燕双飞 提交于 2019-12-20 04:20:50
问题 I have created a game using SpriteKit (GameScene and GameViewController) and Objective-C. Everything there works fine. Within the same App I have created a UIViewController and a second viewController in storyboard that uses CollectionView. I have the collectionView loading the array. I want to be able to tap on a collectionView Cell and have it open the gameView. Which I can do. However I would like to pass some information from the collectionView to the GameScene so I can load the

Manually scrolling two UICollectionViews showing the same content

风格不统一 提交于 2019-12-20 03:55:12
问题 As the title suggest, I have a UIViewController with two UICollectionViews which are displaying the same content in a horizontal fashion. The main one shows one photo at a time, the thumbs one shows several. I have overridden the UIScrollViewDelegate method and added some code so that when the user scrolls the main CV, then the thumbs CV scrolls too. However I would like to enable the opposite as well (scroll the thumbs which will quickly move the main). However i'm getting a feedback effect.

UICollectionView not loading fully until I scroll

感情迁移 提交于 2019-12-20 03:21:57
问题 I have a collection view that I want to display hourly weather in. I seem to have a problem with loading the cell, and for some reason scrolling forwards and then back loads the cell fully. Before I scroll the collection view, all of the constraints do not work and one label doesn't show it's info. Before scrolling After scrolling (this is how I want the cells to look like) func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { // #warning Incomplete implementation,

Add Navigation Bar in UICollectionView in swift 4, iOS 11

别等时光非礼了梦想. 提交于 2019-12-20 03:12:40
问题 After upgrading the iOS 11 and swift 4(Xcode 9), I got lots of UI problem. :( The most unsolvable problem is Navigation Problem. I put the Navigation Bar in UICollectionView Controller . Navigation bar height does not show properly and however I write the code. I set navigation bar height "100". I write this code in ViewDidLoad(). if #available(iOS 11.0, *) { print("IOS 11 Screen") UINavigationBar.appearance().largeTitleTextAttributes = [ NSForegroundColorAttributeName: UIColor.white, ]

How can I use switch statement to implement collectionView function in Swift?

廉价感情. 提交于 2019-12-19 11:55:29
问题 I am new to swift and trying to implement collectionView function in a ViewController.Now I have three types of UICollectionViewCell,here is my code: func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { if collectionView == self.collectionViewCategory { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: categoryIdentifier, for: indexPath as IndexPath) as! CategoryCell cell.CategoryIcon.image = self.categoryItems

How to make prepareForSegue with UIcollectionView

假如想象 提交于 2019-12-19 09:17:55
问题 I have problem with this code: func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { self.performSegueWithIdentifier("showDetailsSegue", sender: self) } override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue.identifier == "showDetailsSegue" { let detailsVC: DetailsViewController = segue.destinationViewController as! DetailsViewController let indexPaths = self.collectionView.indexPathsForSelectedItems() let

Swift 3: How to center horizontally the last row of cells in a UICollectionView with only one section?

和自甴很熟 提交于 2019-12-19 09:14:24
问题 I'm using a UICollectionView with only one section. Here's some visualization: [ x x x ] [ x x x ] [ x x ] If the last row in the UICollectionView does not have all 3 cells filled, I'd like to center those cells like so: [ x x x ] [ x x x ] [ x x ] I've tried to implement solutions from the following places: How to center horizontally UICollectionView Cells? How to center align the cells of a UICollectionView? However, the solutions shifts all the cells, and I'd like to only shift the LAST

UICollectionView not able to scroll to see the entire last row

╄→гoц情女王★ 提交于 2019-12-19 09:01:30
问题 I have a UICollectionView with size: 768x1024 with a navbar on top. My custom UICollectionViewCells are of size 200x200 . The problem is that when I keep adding cells and I reach the bottom row, I can only see part of the 200x200 cell. It won't let me scroll further before it bounces back up. Any ideas on what the problem could be? EDIT: I add cells via: insertItemsAtIndexPaths: 回答1: The issue was just adding AutoLayout constraints to the View Controller which housed the UICollectionView . To

Swift - could not dequeue a view of kind: UICollectionElementKindCell with identifier

孤街浪徒 提交于 2019-12-19 05:31:16
问题 I got this error message when trying to load UICollectionView. 2015-07-23 16:16:09.754 XXXXX[24780:465607] Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier CollectionViewCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard' First throw call stack: My code @IBOutlet var collectionView: UICollectionView! func collectionView

How to set UILabel on UICollectionViewCell?

♀尐吖头ヾ 提交于 2019-12-19 04:53:58
问题 I've done this several dozen times with custom and standard UITableView cells. All my outlets are connected. The UILabel is a subview of my UICollectionViewCell in IB. My UICollectionViewCell object inherits the proper class in identity inspector. How do I set UILabel on UICollectionViewCell ? MyCell.m -(void)setCellName:(NSString *)cellName { self.cellLabel.text = cellName; } ViewController.m - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath: