Click here to Skip to main content
15,889,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a UICollectionView that I set the translatesAutoresizingMaskIntoConstraints to NO, and added some constraints. When I try scrolling it to an indexPath:
Objective-C
[self.datesCollectionView selectItemAtIndexPath:selectedCellIndexPath animated:YES scrollPosition:UICollectionViewScrollPositionCenteredHorizontally];

Then it completely ignores that, and doesn't scroll. But when I remove translatesAutoresizingMaskIntoConstraints, then it scrolls, but the constraints are ignored.

My question is, How can I get the collectionView to scroll to an indexPath when translatesAutoresizingMaskIntoConstraints is set to NO?
Posted

1 solution

You have some autolayout issue. Watch the WWDC Session "Mystery of Autolayout Part 2" to understand what you need to change. translatesAutoresizingMaskIntoConstraints should be NO.

The scrolling works fine, but be aware that only the selected cell gets simply shown. if partly visible nothing happens. So you may need some additional logic to do what you want.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900