collectionView 手写初始化

  针对collectionView的初始化不能直接[[UICollectionView allocinitWithFrame:self.view.frame]这样写,需要对collectionView的flowout进行设置,否则会报错。

   UICollectionViewFlowLayout *flowLayout=[[UICollectionViewFlowLayout alloc ]init];

    UICollectionView *collectionView=[[UICollectionView alloc] initWithFrame:self.view.frame collectionViewLayout:flowLayout];

    collectionView.frame = CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT-64-49);

    collectionView.delegate = self;

    collectionView.dataSource = self;

    [self.view addSubview:collectionView];

你可能感兴趣的:(ios,frame,CollectionView,手写设置)