0

Statically I have mentioned the number of sections for the UICollectionView as 3 as shown in the below:

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
            return 3;
    }

Now I am trying to display the second section when the application launches instead of showing the first section.As UICollectionView is a subclass of UIScrollView. I wrote the code that:

[mCollectionView scrollRectToVisible:CGRectMake(0, 600, 320, 568) animated:YES];

but it was displaying the first section only.Is there any other way to display the second section in UICollectionView.

UserDeviOS
  • 89
  • 1
  • 2
  • 10

1 Answers1

1

Try this

[collectionview scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1] atScrollPosition:UICollectionViewScrollPositionTop animated:YES];
Kalpesh
  • 5,336
  • 26
  • 41
  • could be good to use animated: NO to avoid the user watching the scrollview scroll on the beginning (that may confuse them) – Heavy_Bullets Aug 22 '13 at 05:56
  • Hi @kalpesh I have tried the solution which you have given but I am facing an issue that the section header is hiding as it was displaying from cell index position when I scroll to top then it was showing the section header but when the application launches the section header was not shown. – UserDeviOS Aug 22 '13 at 09:20
  • @usernew i have check actually it depend on your uicollection view cell size and number of item in section . I think – Kalpesh Aug 22 '13 at 09:55