上出于某种原因,当我UICollectionView的第一页上UICollectionView第二页内容, 它显示从第二页的图像。
而且我还注意到,该网页不居中....
我手动设置
pageControl.numberOfPages = 3
所以,我有三个页面图像。 每个页面显示8项(理想情况下......)。
这是在viewDidLoad中:
UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc] init];
[layout setSectionInset:UIEdgeInsetsMake(10, 10, 15, 10)];
[layout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
[self.collectionView setCollectionViewLayout:layout];
self.collectionView = [[UICollectionView alloc] initWithFrame:keyboardRect collectionViewLayout:layout];
self.collectionView.dataSource = self;
self.collectionView.delegate = self;
self.collectionView.pagingEnabled = true;
self.collectionView.alwaysBounceHorizontal = true;
self.collectionView.contentSize = CGSizeMake(keyboardRect.size.width , keyboardRect.size.height);
self.collectionView.showsHorizontalScrollIndicator = false;
UINib *cellNib = [UINib nibWithNibName:@"TopCell" bundle:nil];
[self.collectionView registerNib:cellNib forCellWithReuseIdentifier:@"cellIdentifier"];
[self.collectionView registerClass:[TopCollectionViewCell class] forCellWithReuseIdentifier:@"cellIdentifier"];
[self.collectionView setBackgroundColor:[UIColor redColor]];
[self.view addSubview:self.collectionView];
当我试图从
[layout setSectionInset:UIEdgeInsetsMake(10, 10, 15, 10)];
它只是使事情更糟提高左,右插图。它只会在第一页上看起来很好, 但是第二页和第三页将会关闭。
这里是我的一些代码:
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return [self.Images count];
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return CGSizeMake(70, 70);
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView*)collectionView {
return 3;
}
预先感谢您!
为collectionview和check设置pagingEnabled = TRUE。 – iOSEnthusiatic
它设置为true。 (上面的代码) –