簡體   English   中英

如何為uicollectionview設置約束,以便它與所有設備一起調整

[英]how to set constraint for uicollectionview so that it adjusts with all devices

在此處輸入圖片描述 / Users / seedoo / Desktop / Simulator屏幕截圖2017年7月28日,1.33.59 PM.png / Users / seedoo / Desktop / Simulator屏幕截圖2017年7月28日,1.34.37 PM.png

iPhone 5s裝置的電池間距比6s的小,請讓我知道如何解決這個問題。

嘗試一下:根據需要在所有方法中進行更改

目標C

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    return  CGSizeMake(collectionView.frame.size.width/2 -5, 135); // 2 is indicates number of cell in sigle row
}

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

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
    return 10.0f;
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
    return 10.0f;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM