![](/img/trans.png)
[英]why selected cell in collection view doesn't show correctly in the UICollection View Swift 3?
[英]Why the Collection Cell doesn't show on the collectionView?
我是IOS的新手,我想通過IOS中的collectionView
實現相冊。
我創建了如下圖所示的View
(名稱: AITCameraCollectionBrowser.xib )。
並創建另一個AITPhotoCell.xib file
,如下圖所示。
我希望cell
顯示在collectionView
。
但是AITCameraCollectionBrowser
中的button
和collectionView
均不顯示。
而且我不知道為什么“視圖”不顯示任何內容?
以下代碼在AITCameraCollectionBrowser.m
viewDidLoad
中
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[self.collectionview registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
self.collectionview.dataSource = self;
self.collectionview.delegate = self;
[self.collectionview addSubview:_collectionview];
UINib *nib = [UINib nibWithNibName:@"AITPhotoCell" bundle:nil];
[self.collectionview registerNib:nib forCellWithReuseIdentifier:[AITPhotoCell reuseIdentifier]];
}
為什么AITCameraCollectionBrowser
中的button
和collectionView
不顯示。
我在viewDidLoad
缺少什么嗎?
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
[flowLayout setItemSize:CGSizeMake(75,75)];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
[self.collectionview setCollectionViewLayout:flowLayout];
[self.collectionview registerNib:[UINib nibWithNibName:@"AITPhotoCell" bundle:nil] forCellWithReuseIdentifier:@"CellIdentifier"];
試試這個..它的工作.. :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.