UICollectionViewController简单操作
来源:互联网 发布:js如何验证手机号码 编辑:程序博客网 时间:2024/06/04 18:46
//// MyCollectionViewCell.h// AppUI组件学习//// Created by 麦子 on 15/6/24.// Copyright (c) 2015年 麦子. All rights reserved.//#import <UIKit/UIKit.h>@interface MyCollectionViewCell : UICollectionViewCell@property(nonatomic,strong)UILabel *label;@end
//// MyCollectionViewCell.m// AppUI组件学习//// Created by 麦子 on 15/6/24.// Copyright (c) 2015年 麦子. All rights reserved.//#import "MyCollectionViewCell.h"@implementation MyCollectionViewCell@synthesize label;- (instancetype)initWithFrame:(CGRect)frameA{ self = [super initWithFrame:frameA]; if (self) { self.backgroundColor = [UIColor orangeColor]; label = [[UILabel alloc] init]; label.frame = CGRectMake(25, 35, 50, 30); label.backgroundColor = [UIColor purpleColor]; [self addSubview:label]; } return self; }@end
//// MyCollectionViewController.m// AppUI组件学习//// Created by 麦子 on 15/6/24.// Copyright (c) 2015年 麦子. All rights reserved.//#import "MyCollectionViewController.h"#import "MyCollectionViewCell.h"@interface MyCollectionViewController ()@end@implementation MyCollectionViewControllerstatic NSString * const reuseIdentifier = @"Cell";- (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; self.title = @"集合视图"; // Uncomment the following line to preserve selection between presentations // self.clearsSelectionOnViewWillAppear = NO; // 注册这个 [self.collectionView registerClass:[MyCollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier]; }- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; }#pragma mark <UICollectionViewDataSource>// 分区- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1;}// 一个区有多少行- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return 10;}- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { MyCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; cell.label.text = [NSString stringWithFormat:@"%ld",indexPath.row]; cell.label.textColor = [UIColor redColor]; cell.label.textAlignment = NSTextAlignmentCenter; return cell;}#pragma mark <UICollectionViewDelegate>/*// Uncomment this method to specify if the specified item should be highlighted during tracking- (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath {return YES;}*//*// Uncomment this method to specify if the specified item should be selected- (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath { return YES;}*//*// Uncomment these methods to specify if an action menu should be displayed for the specified item, and react to actions performed on the item- (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath {return NO;}- (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {return NO;}- (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {}*/@end
// 集合视图 // 创建流逝布局 UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init]; // 单元格大小 flow.itemSize = CGSizeMake(100, 100); // 滚动的方向 flow.scrollDirection = UICollectionViewScrollDirectionVertical; // 设置边界 flow.sectionInset = UIEdgeInsetsMake(40, 0, 0, 0); MyCollectionViewController *collectionDemo = [[MyCollectionViewController alloc] initWithCollectionViewLayout:flow];
0 0
- UICollectionViewController简单操作
- UICollectionViewController简单操作(2)
- UICollectionViewController
- UICollectionViewController
- iOS UICollectionViewController基本使用方法和简单的相册实现
- (十)swift UICollectionViewController常用操作(swift 九宫格)
- UICollectionViewController用法
- 关于UICollectionViewController
- UICollectionView \ UICollectionViewController
- UICollectionViewController相关
- Storyboard创建使用UICollectionViewController
- UICollectionView--UICollectionViewController
- UIKite/UICollectionViewController/ScrollView
- UICollectionViewController 版本新特性
- UICollectionViewController 集合视图控制器
- UICollectionViewController瀑布流
- 自定义UICollectionViewController只读UICollectionViewLayout
- UICollectionViewController相关注意事项
- Android中运行sh脚本提示找不到文件或路径(no such file or directories)
- Quartz的cron表达式
- 【动态规划】【多重背包】[HDU 1291]悼念512汶川大地震遇难同胞――珍惜现在,感恩生活
- [一起学Hive]之七-向Hive表中加载数据
- 对于return new A();
- UICollectionViewController简单操作
- sgu-264. Travel
- Color the ball(树状数组之插点问线问题)
- 算法准备
- c语言中通过指针将数值赋值到制定内存地址
- delphi 控件 combobox常识
- 深入理解HTTP Session
- C常用的对数组操作的几个方法
- Git使用技巧(整理)三 实战