Ios 将CollectionView单元格与所有设备的Autolayout对齐

Ios 将CollectionView单元格与所有设备的Autolayout对齐,ios,xcode,uicollectionview,autolayout,Ios,Xcode,Uicollectionview,Autolayout,我对xCode 9的约束有问题。 我有一个UIVIewController,其中包含一个UICollectionView,显示当前月份的天数,一切正常,但我在各种设备上的单元格有问题 collectionView使用分页进行单元格滚动 在这里你可以看到,在iPhone8 plus上没问题,但在iPhone上,如果电池被切断。。 我为我的collectionView设置了UICollectionViewFlowLayout,但仍然存在问题。。。可能是错误的约束条件,但我不明白这些约束条件中哪一

我对xCode 9的约束有问题。 我有一个UIVIewController,其中包含一个UICollectionView,显示当前月份的天数,一切正常,但我在各种设备上的单元格有问题

collectionView使用分页进行单元格滚动


在这里你可以看到,在iPhone8 plus上没问题,但在iPhone上,如果电池被切断。。

我为我的collectionView设置了UICollectionViewFlowLayout,但仍然存在问题。。。可能是错误的约束条件,但我不明白这些约束条件中哪一个是错误的


这是我用于自定义单元格的约束的图像


以下是我在UIViewController中设置的自定义UIView的约束条件


我还向您展示了我使用的代码,也许错误就在这里

-(instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder: aDecoder];
    if (self) {

    }
    return self;
}

-(void)setupContent:(UIView *)controller {

    _arrayWeek = [[NSMutableArray alloc] init];
    _arrayDay = [[NSMutableArray alloc] init];

    UICollectionViewFlowLayout *smartLayout = [[UICollectionViewFlowLayout alloc] init];
    _smartCalendar = [[UICollectionView alloc] initWithFrame:self.bounds collectionViewLayout:smartLayout];

    //////// Collection View ////////
    _smartCalendar.delegate = self;
    _smartCalendar.dataSource = self;
    _smartCalendar.backgroundColor = [UIColor clearColor];
    _smartCalendar.pagingEnabled = YES;

    UINib *nib = [UINib nibWithNibName:@"UDSmartCalendarCell" bundle: nil];
    [_smartCalendar registerNib:nib forCellWithReuseIdentifier:cellID];

    _smartCalendar.translatesAutoresizingMaskIntoConstraints = NO;
    [self addSubview:_smartCalendar];

     //////// CONSTRAINT COLLECTION VIEW ////////
    [_smartCalendar.trailingAnchor constraintEqualToAnchor:self.trailingAnchor constant:0.0].active = YES;
    [_smartCalendar.topAnchor constraintEqualToAnchor:self.topAnchor constant:0].active = YES;
    [_smartCalendar.widthAnchor constraintEqualToAnchor:self.widthAnchor].active = YES;
    [_smartCalendar.heightAnchor constraintEqualToConstant:60].active = YES;

     //////// FLOW LAYOUT COLLECTION VIEW////////
    smartLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    CGFloat width = floorf(_smartCalendar.frame.size.width  / 6);
    smartLayout.itemSize = CGSizeMake(width, 50);
    smartLayout.minimumInteritemSpacing = 3;
    smartLayout.minimumLineSpacing =3;
    smartLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    _smartCalendar.collectionViewLayout = smartLayout;
    _smartCalendar.showsHorizontalScrollIndicator = NO;


    [self buildSmartCalendarWithWeekArray:_arrayWeek andDay:_arrayDay];
    [self scrollToItemToday];

}