uicollectionviewcell

How do I use UILongPressGestureRecognizer with a UICollectionViewCell in Swift?

99封情书 提交于 2019-11-29 20:43:06
I would like to figure out how to println the indexPath of a UICollectionViewCell when I long press on a cell. How can I do that in Swift? I have looked all over for an example of how to do this; can't find one in Swift. ztan First you your view controller need to be UIGestureRecognizerDelegate . Then add a UILongPressGestureRecognizer to your collectionView in your viewcontroller's viewDidLoad() method class ViewController: UIViewController, UIGestureRecognizerDelegate { override func viewDidLoad() { super.viewDidLoad() let lpgr = UILongPressGestureRecognizer(target: self, action:

How to add views between UICollectionViewCells in a UICollectionView?

╄→гoц情女王★ 提交于 2019-11-29 19:27:48
I'm trying to add UIView s between my UICollectionViewCell s in my UICollectionView and I don't know how I could do that. I'm trying to accomplish something like this: I'll probably need to write a custom UICollectionViewLayout , but I don't really know where to start. I studied more of how UICollectionViewLayout s work and figured out how to solve it. I have an UICollectionReusableView subclass called OrangeView that will be positioned between my views, than I wrote an UICollectionViewFlowLayout subclass called CategoriesLayout that will deal with my layout. Sorry for the big block of code,

Can't get UICollectionView to display cells

╄→尐↘猪︶ㄣ 提交于 2019-11-29 19:10:59
问题 I'm trying to get a UICollectionView to display inside a modally presented view controller. The app is for iPad iOS 7. I've created subclass of UIViewController (with a nib) and added it like this: MyViewController *controller = [[MyViewController alloc] init]; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller]; navController.modalPresentationStyle = UIModalPresentationFullScreen; navController.navigationBar.barStyle =

UITextView font to always be fixed size

一曲冷凌霜 提交于 2019-11-29 17:32:16
I have a UICollectionView with cells sized to the same aspect ratio as a4 page. And with different screen sizes I would like for that text to be sized at fixed 12pt (that would be calculated to that UICollectionview cell), which would look bigger on the iPad and smaller on iPhone. So having a fixed font size isn't an option... Coding var fontSize : CGFloat = 12.0 // DEFAULT SIZE In your ViewDidLoad if UIDevice().userInterfaceIdiom == .phone { switch self.view.frame.size.height { case 480: fontSize = 12.0 case 568: fontSize = 14.0 case 667: fontSize = 16.0 case 736: fontSize = 17.0 case 812:

UICollectionView 3 column grid, 1px space?? (image included)

一曲冷凌霜 提交于 2019-11-29 16:59:02
问题 I have setup a UICollectionView with a FlowLayout that leaves no space in between cells in either the vertical or horizontal directions. I have everything working, yet there is an odd 1px space between the 2nd and 3rd column and I have no idea why!? I have verified the 1px gap shows up both in iOS simulator and on a real device. Has anybody experienced this? My UIViewController is a delegate/datasource of the following: class MyViewController: UIViewController, UICollectionViewDelegate,

UICollectionView image on cell memory warning

巧了我就是萌 提交于 2019-11-29 16:55:07
im using Xcode 4.6.1, iOS SDK 6.1, ARC and Storyboards, testing device iphone 4S running 6.1.3 I'm having a little trouble configuring a collectionviewcell containing pictures, there thing is when i try to add some custom pictures on the cell, the memory just jump directly by 30-40mb each picture, the picture are taking directly on the device camera and saved on documents directory, maybe you can help me with this. here are the codes i use: --the code to load the images path on an array imagesArray -(void) llenarArregloImagenes { imagesArray=[[NSMutableArray alloc]init]; NSFileManager *fileMgr

Collection View Cells have incorrect content size

≡放荡痞女 提交于 2019-11-29 16:46:59
I made a collection view with 144 cells. I have them setup for single selection. I have been playing with the settings I have for a while now, but any setup that actually displays the cells correctly has this problem where two specific cells consistently are the wrong size. Note that the problem only happens when testing on the iPad pro. They will resize often under conditions that I can't replicate when changing their image to others back and forth. I try to only call reloadData() when absolutely necessary, and call the reload individual cell at indexPath function. I have tested about

UICollection View inside Table Cell does not show images in Swift 3

拥有回忆 提交于 2019-11-29 16:45:56
I put UICollectionView inside table cell in Home page. Each category row has their contents image. But, my problem is that when I run the app, the images under second row/second category do not show whenever I run the app. The images will show after I click more button and it will goes to details UI. Then, I click on Back button and reach the Home page. At this time, the images shows properly. I tried many codes but I don't know where it is wrong. override func viewWillLayoutSubviews() { super.viewWillLayoutSubviews() tableView.reloadData() self.tableView.reloadData() self.tableView

Getting data from a textfield inside a prototype uicollectionviewcell

南楼画角 提交于 2019-11-29 16:10:55
I have a UICollectionViewCell which is prototype cell, I have a textfield in it, which by default present in all of them. (which is what I want). I want to be able to when the user inputs a value in these textfields to be able to retrieve the data and the cell which the data was put into(maybe the number of the row). I have seen a few other related questions but none seems to work for me. Any ideas? @interface ViewController () { NSArray *collections, *numbers; NSMutableArray *selectedItemsArray; UICollectionViewCell *cell; UITextView *text1Field; NSIndexPath *indexPath1; } - (void)viewDidLoad

UICollectionView with multi-select won't select more than a dozen of items

北城以北 提交于 2019-11-29 14:31:10
问题 When using a UICollectionView with allowsMultipleSelection set to YES only a dozen items are selectable. UICollectionViewDelegate stops calling collectionView:didSelectItemAtIndexPath: . It seems very random. You can select a few items, scroll down, select some more, and at some point you're not able to select any more items. When the cell is smaller you seem to be able to select more items. The larger the cell, the fewer items you're able to select before it stops working. 回答1: I have