vin*_*n25 8 uitabbar ios uicollectionview
我想知道什么是最好的方法来实现像iOS一样的视图分页器与iOS上的标签,如在FIFA世界杯应用程序上找到的 
我能想到的各种方法是:
我目前的实现 - 截至目前我有三个标签栏条目.我为每个人都有单独的视图控制器.这是我使用水平分页集合视图实现它的方式:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
NSInteger indexNumber = indexPath.row;
UICollectionViewCell *cell;
switch (indexNumber) {
case 0:
cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"collectionViewCell1" forIndexPath:indexPath];
[cell.contentView addSubview:self.firstViewControllerObject.view];
break;
case 1:
cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"collectionViewCell2" forIndexPath:indexPath];
[cell.contentView addSubview:self.secondViewControllerObject.view];
break;
case 2:
cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"collectionViewCell3" forIndexPath:indexPath];
[cell.contentView addSubview:self.thirdViewControllerObject.view];
break;
default:
break;
}
return cell;
}
Run Code Online (Sandbox Code Playgroud)
我无法找到更好地管理细胞的方法,因此我制作了不同的实体.如何使用这种方法做得更好,或者如果这种方法不好,我应该使用什么?
| 归档时间: |
|
| 查看次数: |
7595 次 |
| 最近记录: |