我想创建具有tumbnail图像的电影条带类型视图和具有图像名称的标签。通过点击缩略图图像,大图像应该打开。我不知道应该使用scrollview或collectionview。
答案 0 :(得分:0)
使用Collectionview,因为它是专门针对您所要求的要求而设计的。
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
//write your code here just like tableview
return 3;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
//configure your cells here
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
// this method for handling your selection of particular cell
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionView *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
return 5; // This is the minimum inter item spacing, can be more
}
答案 1 :(得分:-1)
swift 3中的CollectionView ......
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
//write your code here just like tableview
return 3
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
//configure your cells here
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
// this method for handling your selection of particular cell
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionView, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return 5
// This is the minimum inter item spacing, can be more
}