uicollectionview

How to scroll UICollectionViewCell programmatically in IOS?

删除回忆录丶 提交于 2019-12-31 16:11:04
问题 I have a vertical UICollectionView with each cell taking up the entire self.view.frame I can easily swipe upwards to page to the next cell, but I would like to do the same thing with the press of a button. I've tried using: - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated And: - (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated They work but they temporarily "White-Out" the currentCell to present the nextCell, while the swiping shows both cells during the

UICollectionViewFlowLayout subclass crashes accessing array beyond bounds while scrolling and reloading

☆樱花仙子☆ 提交于 2019-12-31 12:08:53
问题 I have a UICollectionView that uses a custom subclass of UICollectionViewFlowLayout to make the section headers stick to the top of the screen while scrolling just like UITableView's plain style. My code is based on this approach: http://blog.radi.ws/post/32905838158/sticky-headers-for-uicollectionview-using In addition, the collection view is set up to load more results when the user scrolls to the bottom. That is, when the user gets to the bottom of the collection view, a web request loads

How to change UICollectionView Scroll Direction?

自作多情 提交于 2019-12-31 10:43:44
问题 I have successfully implemented a UICollectionView . Is it possible to change the scrollDirection ? Can you please show how to implement it programmatically? 回答1: This is how you create it in code with UICollectionViewFlowLayout let layout = UICollectionViewFlowLayout() layout.scrollDirection = .vertical let collectionView = UICollectionView(frame: frame, collectionViewLayout: layout) or if you are working with an existent collection view if let layout = collectionView.collectionViewLayout as

UICollectionView: How to get the header view for a section?

半城伤御伤魂 提交于 2019-12-31 08:44:15
问题 There is a method to get a cell by indexPath ( UICollectionView cellForItemAtIndexPath: ). But I can"t find a method to get one of the supplementary views like a header or footer, after it has been created. Any ideas? 回答1: UPDATE As of iOS 9, you can use -[UICollectionView supplementaryViewForElementKind:atIndexPath:] to get a supplementary view by index path. ORIGINAL Your best bet is to make your own dictionary mapping index paths to supplementary views. In your collectionView

How to detect double-taps on cells in a UICollectionView

一笑奈何 提交于 2019-12-31 08:08:36
问题 I want to respond to double-taps on cells in a UICollectionView, and have a double-tap action cancel cell selection. This is what I've tried: UITapGestureRecognizer *tapRecogniser = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)]; tapRecogniser.numberOfTapsRequired = 2; for (UITapGestureRecognizer *recogniser in [self.collectionView gestureRecognizers]) { [recogniser requireGestureRecognizerToFail:tapRecogniser]; } [self.collectionView

UICollectionView effective drag and drop

可紊 提交于 2019-12-31 08:04:31
问题 I am currently trying to implement the UITableView reordering behavior using UICollectionView. Let's call a UItableView TV and a UICollectionView CV (to clarify the following explanation) I am basically trying to reproduce the drag&drop of the TV, but I am not using the edit mode, the cell is ready to be moved as soon as the long press gesture is triggered. It works prefectly, I am using the move method of the CV, everything is fine. I update the contentOffset property of the CV to handle the

How to transition from UICollectionView to UIViewController like Pinterest/Evernote

a 夏天 提交于 2019-12-31 07:58:21
问题 I have a UICollectionView and when an item is selected, I'd like it to animate full screen. So it would transition from the size of the cell to full screen and become a UIViewController. Pinterest and Evernote both have this behavior where tapping on a cell transitions the cell into a full screen view controller. Are there any example of how this is done? I've searched several projects, but haven't found any illustrating on transitioning a cell to full screen view controller. Pinterest

Setting size of UICollectionViewCell in a way that there is no interim spacing in between

空扰寡人 提交于 2019-12-31 07:09:08
问题 I'm using an UICollectionView on which I want to place seven cells side by side. The whole screen should be used for this. Currently, I'm using the width of the collection view and divide it by seven. Now I get an item width of 45.71429 on an iPhone 4. Between some cells there is an interim spacing. How can I handle this? I want to fill out the whole screen and all items should have the same size. One option which comes to my mind is to round the value and use the remaining value as inset.

UIButton does not function in collectionView cell

社会主义新天地 提交于 2019-12-31 06:25:08
问题 I am trying to create this collection view cells with kinda paging behavior. In every cell; I made a card flip animation. But flip function does not work. I know that function is OK because; before I create these UICollectionViewCell model, I tried everything in UICollectionView itself and it worked out perfect. But since I need paging behavior, I need multiple pages with card view inside and in every cell when user tabs the card it should flip. So, after I migrated all the code from

UICollectionView - When the keyboard appears the entire collection view is shifted with the keyboard

 ̄綄美尐妖づ 提交于 2019-12-31 05:40:30
问题 This isn't my desired effect. This only happens when the collection view is set to horizontal flow layout. I've seen a few other posts regarding this very same issue but none of the provided answers have worked. Has anyone found a solution? I've provided two screenshots showing a UITextField before the keyboard is triggered and after. As you can see the UITextField along with the entire collection view (which can't be seen) is pushed up along with the keyboard. Usually the keyboard is