亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

iOS學習之UICollectionView使用注解

2019-11-14 18:32:32
字體:
來源:轉載
供稿:網友
#import "ViewC.h"
#import "CLCollectionViewCell.h"
#import "HeadView.h"
#import "FootView.h"
static NSString *cellIdentifier = @"cell";
static NSString *headerIdentifier = @"header";
static NSString *footerIdentifier = @"footer";
@interface ViewC ()<uicollectionviewdatasource, uicollectionviewdelegate,="" uicollectionviewdelegateflowlayout="">
 
@end
 
@implementation ViewC
 
 
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
 
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor lightGrayColor];
    UICollectionViewFlowLayout *flowLayout= [[UICollectionViewFlowLayout alloc] init];
    flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;//滾動方向
    flowLayout.minimumLineSpacing = 10.0;//行間距(最小值)
    flowLayout.minimumInteritemSpacing = 50.0;//item間距(最小值)
    flowLayout.itemSize = CGSizeMake(50, 50);//item的大小
    flowLayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);//設置section的邊距
    flowLayout.headerReferenceSize = CGSizeMake(320, 20);
    flowLayout.footerReferenceSize = CGSizeMake(320, 20);
    //第二個參數是cell的布局
    UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 320, 568) collectionViewLayout:flowLayout];
    [flowLayout release];
    collectionView.dataSource = self;
    collectionView.delegate = self;
    collectionView.backgroundColor = [UIColor orangeColor];
    //1 注冊復用cell(cell的類型和標識符)(可以注冊多個復用cell, 一定要保證重用標示符是不一樣的)注冊到了collectionView的復用池里
    [collectionView registerClass:[CLCollectionViewCell class] forCellWithReuseIdentifier:cellIdentifier];
     
    //第一個參數:返回的View類型
    //第二個參數:設置View的種類(header, footer)
    //第三個參數:設置重用標識符
    [collectionView registerClass:[HeadView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:headerIdentifier];
    [collectionView registerClass:[FootView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:footerIdentifier];
    [self.view addSubview:collectionView];
    [collectionView release];
}
 
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
 
#PRagma mark - UICollectionViewDataSource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 10;
}
 
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 10;
}
 
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    //2 從復用池中找cell(1:cell的標示符 2:indexPath決定系統用不用再給你創建cell, 不用創建的話, 就直接使用之前的cell)
    CLCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
    cell.backgroundColor = [UIColor yellowColor];
    cell.textLabel.text = [NSString stringWithFormat:@"%ld", (long)indexPath.row];
    return cell;
}
 
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    if (kind == UICollectionElementKindSectionHeader) {
        HeadView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:headerIdentifier forIndexPath:indexPath];
        headerView.textLabel.text = @"讓我組成頭部!";
        headerView.textLabel.textAlignment = NSTextAlignmentCenter;
        headerView.textLabel.textColor = [UIColor whiteColor];
        return headerView;
    }
    FootView *footerView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:footerIdentifier forIndexPath:indexPath];
    footerView.textLabel.text = @"讓我組成尾部!";
    footerView.textLabel.textAlignment = NSTextAlignmentCenter;
    footerView.textLabel.textColor = [UIColor whiteColor];
    return footerView;
}
 
#pragma mark - UICollectionViewDelegate
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"%d %d", indexPath.section, indexPath.row);
}
 
#pragma mark - UICollectionViewDelegateFlowLayout
/*
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
     
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
     
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
     
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
{
     
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
{
     
}
 */
/*
#pragma mark - Navigation
 
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
 
@end

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
欧美精品免费在线观看| 中文字幕亚洲一区二区三区| 97久久伊人激情网| 亚洲人成网站免费播放| 日韩av在线直播| 中文日韩电影网站| 青青a在线精品免费观看| 国产精品18久久久久久首页狼| 亚洲人成在线播放| 丝袜亚洲欧美日韩综合| 欧美在线观看日本一区| 亚洲国产高潮在线观看| 亚洲精品欧美一区二区三区| 久久综合伊人77777蜜臀| 成人网在线免费看| 一区二区三区国产在线观看| 国产精品免费福利| 91久久国产婷婷一区二区| 成人激情在线观看| 亚洲欧美日韩综合| 国产精品视频网站| 国产精品视频yy9099| 亚洲最大中文字幕| 亚洲人成在线一二| 日韩一区av在线| 亚洲欧美另类在线观看| 亚洲日韩欧美视频一区| 日本最新高清不卡中文字幕| 欧美成人午夜影院| 日韩电影免费观看中文字幕| 日韩av大片在线| 欧美性资源免费| 国产在线高清精品| 欧美亚洲成人精品| 91福利视频在线观看| 国产精品视频男人的天堂| 尤物yw午夜国产精品视频明星| 亚洲精品视频久久| 美女撒尿一区二区三区| 日本免费一区二区三区视频观看| 国产欧亚日韩视频| 视频在线观看一区二区| 国产精品一区二区在线| 一区二区三区无码高清视频| 国产一级揄自揄精品视频| 91麻豆国产精品| 日韩精品亚洲元码| 精品国产一区二区三区久久狼黑人| 17婷婷久久www| 亚洲精品美女免费| 成人免费在线视频网站| 久久99久久亚洲国产| 日韩黄在线观看| 欧美国产精品va在线观看| 国产精品久久久久久久久久尿| 这里只有精品在线观看| 亚洲精品国产综合久久| 91在线色戒在线| 久久男人av资源网站| 亚洲影视九九影院在线观看| 中国人与牲禽动交精品| 日韩在线观看网址| 欧美性猛交xxxx富婆弯腰| 日韩中文在线视频| 伊人伊成久久人综合网站| 欧美激情a∨在线视频播放| 久久国产精品久久精品| 国产91久久婷婷一区二区| 日韩欧美成人精品| 一夜七次郎国产精品亚洲| 欧美性xxxxx极品| 欧美高清激情视频| 日韩av在线最新| 久久激情视频免费观看| 亚洲一区二区三区视频| 久久777国产线看观看精品| 国产精品91久久久| 成人国产精品久久久| 久久午夜a级毛片| 国产亚洲精品久久久| 精品国产网站地址| 久久久欧美一区二区| 一区二区三区视频在线| 亚洲人成在线一二| 久久色在线播放| 夜夜嗨av色综合久久久综合网| 亚洲国产中文字幕在线观看| 欧美一级电影久久| 岛国av一区二区在线在线观看| 久久99久国产精品黄毛片入口| 欧美理论片在线观看| 久久九九免费视频| 91极品女神在线| 国产精品美女午夜av| 欧美成人精品三级在线观看| 在线不卡国产精品| 欧美日韩中国免费专区在线看| 国产日产亚洲精品| 亚洲自拍偷拍在线| 久久亚洲私人国产精品va| 色综合久久88| 国产一区二区三区直播精品电影| 日韩欧美中文字幕在线观看| 久久99久久亚洲国产| 亚洲色图欧美制服丝袜另类第一页| 国产精品久久久久久中文字| 色先锋久久影院av| 国产成人自拍视频在线观看| 久久精品小视频| 欧美wwwwww| 亚洲影视九九影院在线观看| 成人性生交大片免费观看嘿嘿视频| 久久久国产精彩视频美女艺术照福利| 日韩精品一区二区三区第95| 亚洲国产91色在线| 亚洲欧美中文日韩v在线观看| 欧美老妇交乱视频| 欧美人与物videos| 欧美日韩亚洲高清| 欧美成在线视频| 亚洲嫩模很污视频| 欧美激情视频在线观看| 日韩视频免费中文字幕| 国产日韩欧美黄色| 成人美女av在线直播| 欧美午夜激情小视频| 97人人爽人人喊人人模波多| 亚洲成人在线网| 久久久久久久影院| 国产福利精品在线| 亚洲一区二区三区777| 中文字幕亚洲一区二区三区| 亚洲国模精品私拍| 1769国内精品视频在线播放| 在线观看久久av| 久久久国产精品免费| 亚洲伊人久久综合| 久久精品91久久久久久再现| 亚洲视频在线观看网站| 欧美电影免费观看网站| 国产自摸综合网| 成人深夜直播免费观看| 亚洲精品福利免费在线观看| 神马久久桃色视频| 国产精品99久久久久久久久| 97精品久久久中文字幕免费| 日本亚洲欧美成人| 欧美日韩国产成人在线观看| 国产美女高潮久久白浆| 韩曰欧美视频免费观看| 狠狠躁夜夜躁人人爽超碰91| 亚洲最大av网| 欧美一区在线直播| 久久影视电视剧免费网站清宫辞电视| 91在线视频九色| 国产精品一区二区女厕厕| 国产成人在线精品| 亚洲国产高清自拍| 91在线观看免费高清完整版在线观看| 国产欧洲精品视频| 欧美成人免费一级人片100| 欧美黑人狂野猛交老妇| 伊人伊人伊人久久| 亚洲精品电影网站|