Tuesday 15 February 2011

ios - UICollectionView: set new layout and target content offset -


I have two subclasses of UICollectionView and UICollectionViewFlowLayout . When a cell is selected, I call setCollectionViewLayout: animated: to switch between layouts. After the transition, the selected cell is centered, which is fine.

Can one be the only focused behavior without really selecting the cell? I have tried to call different code without any success to setContentOffset: animated: Alternatively, do I have a self-defined contentoffset for the layout to display Can I specify?

To be more clear, I have to do something without modifying the code of the cell> selected property:  Enter image details here

Edit # 1

This is what I already have:

  [Self.collectionView selectItemAtIndexPath: Animated Pathway: No Scrollposition: UICollectionViewScrollPositionNone]; [Self.collectionView Setting ViewLayout: Animated Layout: Yes];   

OK:


But if I leave selectItemAtIndexPath :

 < Code> [self. View Collection View Selection: Layout Animated: Yes]; [Self-crawlWall ScrollWives: TargetFrom Animated: Yes];   

This is not ok (animation waving type):

Edit (The answer has been changed after further explanation)

I did the same as Table View. In fact, you call scrollRectToVisible: Animated: Calculating a reset, it will be located at the place of your scroll view where you want to end it, for the exact positioning, I think that according to your view It is necessary to calculate the same size, note that if the size of the material is changing, then the blank should be calculated in the expected final material size. = [With something like this: layoutAttributesForElementsInterecting: rect Super LayoutsAuthentalFormatsSearch: Rect;); If (& lt; test is that we want to make strangers & gt;) {UICollectionViewLayoutAttributes * pose = poses [& lt; To modify the currency of the index & gt;]; Pose.frame = & lt; Some other frames & gt ;; // modify the frame, for example} return pauses; }

You also need to override the layout atvartharthore ITMATI and XPpath with similar logic. When you want to make changes, the next layout will have to invalidate or change your layout. The layout must be given to you, the layout should know what to do, so you can pass relevant data to it or expand UICollectionViewDelegateFlowLayout1 .

No comments:

Post a Comment