uicollectionviewcell

prevent uicollectionview section starting on new line [duplicate]

☆樱花仙子☆ 提交于 2019-12-05 00:29:01
问题 This question already has answers here : UICollectionView remove section breaks with UICollectionViewFlowLayout (2 answers) Closed 2 years ago . I'm using a flow layout on uicollectionview. It all looks great except it seems to start another section on another line. This seems like a sensible default but how do I override this and make the sections flow seamlessly on the same line as if no new section began? Thanks! 回答1: There is a library I found which has this as one of its features

Where to determine the height of a dynamically sized UICollectionViewCell?

筅森魡賤 提交于 2019-12-05 00:00:50
问题 I'm using UICollectionViewFlowLayout. My cells contain UILabels that differ in height (number of lines). It seems that the best way to get the cell height would be in the subclass of UICollectionViewCell , because that is where I set the layout and have access to intrinsic size of my views, BUT: collectionView: layout: sizeForItemAtIndexPath: is called before the collectionView: cellForItemAtIndexPath: delegate method, which means that I need to know the cell height before I have the actual

How to insert images in uicollectionview programmatically?

巧了我就是萌 提交于 2019-12-04 21:32:40
I'm pretty new to Objective-C so hopefully this all makes sense..I ran code provided in first answer Creating a UICollectionView programmatically ..It is working fine .Now i want to add some pictures in cell that can expanded by mouse click .I searched many tutorial but all using nib files or storyboard files .How i can accomplish this task programmatically ? Any help would be greatly appreciated. Thanks in advance. Beginner read tutroial and understand first everyting in below link and apple doc ios-programming-uicollectionview-tutorial-with-sample-code https://developer.apple.com/library/ios

I have a UICollectionView and i want to show an image in a Cell, that goes to a normal ViewController. How do i do that?

霸气de小男生 提交于 2019-12-04 19:47:14
I have a UICollectionViewController (with a navigation controller) and i want to show an image in a Cell that 'pushes' to a normal ViewController (different by every image). How do i do that? Seem you want to build photo gallery by UICollectionView. If use storyBoard, use segue - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"showDetail"]) { NSIndexPath *selectedIndexPath = [[self.collectionView indexPathsForSelectedItems] objectAtIndex:0]; // load the image, to prevent it from being cached we use 'initWithContentsOfFile' NSString

Resizing UICollectionViewCell After Data Is Loaded Using invalidateLayout

本小妞迷上赌 提交于 2019-12-04 19:38:44
问题 This question has been asked a few times but none of the answers are detailed enough for me to understand why/how things work. For reference the other SO questions are: How to update size of cells in UICollectionView after cell data is set? Resize UICollectionView cells after their data has been set Where to determine the height of a dynamically sized UICollectionViewCell? I'm using MVC but to keep things simple lets say that I have a ViewController that in ViewWillAppear calls a web service

UICollectionView with dynamic height not getting same space between cell

喜欢而已 提交于 2019-12-04 17:54:46
问题 I am having similar problem like this I am generating height of view at run time.Here is my code @interface CollectionViewController () { NSMutableArray *arrMain; } @property(nonatomic,strong) NSMutableArray *arrMain; @end @implementation CollectionViewController @synthesize arrMain, - (void)viewDidLoad { [super viewDidLoad]; [cView registerNib:[UINib nibWithNibName:@"CViewCell" bundle:nil] forCellWithReuseIdentifier:kCellID]; CViewFlowLayout *fl = [[CViewFlowLayout alloc] init]; self.cView

Xcode Interface Builder 9.1 Collection View Cells have too small “expected height”

戏子无情 提交于 2019-12-04 16:20:49
问题 Recently, I encountered a problem with the Interface Builder which I failed to solve. I'm using a UICollectionViewController and whenever I add a Cell it immediately shows a orange rectangle (indicating a auto-layout update). Updating the frame/cell doesn't change anything. The warning associated with the orange marking reads "Expected: height=Y, Actual: height=X" where Y is always exactly X-100. That is: When I set a custom cell height of 193, it says "Expected: height=93". This happens no

How can I enable/disable section headers in UICollectionView programmatically?

匆匆过客 提交于 2019-12-04 15:03:37
问题 How can I enable/disable section headers in UICollectionView programmatically? It can be easily done easily done in Storyboard (checkbox), but how about doing it in code? 回答1: You can either use the collectionView:layout:referenceSizeForHeaderInSection: method of the UICollectionViewDelegateFlowLayout and return CGSizeMake(0,0) or set accordingly the headerReferenceSize of UICollectionViewFlowLayout . Edit: headerReferenceSize is actually the property that storyboard uses to show/hide the

How Can I Animate the Size of A UICollectionViewCell on Scroll so the middle one is largest?

大兔子大兔子 提交于 2019-12-04 13:30:33
I have a UICollectionView that shows several rows with one, full-width column (looks like a UITableView) What I'd like to achieve is something similar to this: ... where the middle cell has a much greater height. As the user scrolls up and down, the cells before and after the middle cell animate back to the default height for the given cell. Can somebody outline how I should approach this problem? I use this Swift 3 code in my horizontal UICollectionView . func scrollViewDidScroll(_ scrollView: UIScrollView) { let centerX = scrollView.contentOffset.x + scrollView.frame.size.width/2 for cell in

UICollectionViewCell dynamic height w/two dynamic labels & auto layout

元气小坏坏 提交于 2019-12-04 11:49:43
I have a UICollectionViewCell subclass that's setup with a prototype cell and constraints (every view is connected both vertically and horizontally). I have two labels that can vary in size, they can be either one or two lines. To that end I have set two height constraints on each label, one with a greater than or equal (16 or 20 depending on the label) and a less than or equal (32 or 40 depending on the label). The number of lines on the labels are set to 0. (Though I have tried a variety of settings). Since I've used auto layout and constraints to setup the view I've specified a width on the