【问题标题】:How can I move my cell in objective c for top and right如何在目标 c 中将单元格移动到顶部和右侧
【发布时间】:2018-06-23 11:26:02
【问题描述】:

我是 ios 编程新手。在这里,我只是想将我的单元格向右移动一点……而且我的顶视图也覆盖了屏幕我想减小它的大小以正确地适应视图……我怎样才能做到这一点

【问题讨论】:

  • 根据您的要求设置“section insets” right , left , top , bottom。
  • 如何设置@DixitAkabari
  • 选择“UICollectionview”并进入“显示sizeinspector”并根据您的要求设置“section insets”右、左、上、下。
  • 能否请您出示您的 UICollectionViewDelegateFlowLayout ?

标签: ios objective-c uicollectionview autolayout


【解决方案1】:

使用这行代码。它会在您寻找时将您的单元格放入集合中。

 - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
            CGFloat spaceBetweenCells = 5;
            CGFloat width = (yourMainView.frame.size.width - spaceBetweenCells) / 2;
            CGFloat height = (yourMainView.frame.size.height - spaceBetweenCells) / 2.5;
            return CGSizeMake(width, width*changeHeight+38 );
        }

【讨论】:

    【解决方案2】:

    试试这个

     - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
              return UIEdgeInsetsMake(8, 8, 0, 0);
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-20
      • 2016-09-28
      • 1970-01-01
      • 2018-03-25
      • 2020-12-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多