课后族项目实战(2)-新特性的实现(使用UICollectionView)
来源:互联网 发布:从u盘启动linux系统 编辑:程序博客网 时间:2024/06/06 17:53
1.新特性的显示
在程序第一次启动或者更新到最新版本第一次启动时展示。
2.如何判断?
可以在沙盒中存一个老版本的版本号,与当前版本号进行比较,如果不一样,就显示新特性界面。
3.实现方式
使用UICollectionView。只一行cell,每一个cell的大小就是整个屏幕的大小
*为collection cell设置布局,配置collectionview相关属性
-(instancetype)init{ UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; layout.minimumLineSpacing = 0; layout.itemSize = [UIScreen mainScreen].bounds.size; layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; return [self initWithCollectionViewLayout:layout];}- (void)viewDidLoad { [super viewDidLoad]; self.collectionView.pagingEnabled = YES;//设置分页 self.collectionView.bounces = NO;//滑倒边界不反弹 self.collectionView.showsHorizontalScrollIndicator = NO;//不显示横向滚动条 [self.collectionView registerClass:[TBNewFeatureCell class] forCellWithReuseIdentifier:reuseIdentifier];//注册cell}*设置collectionview的section为1,section里面的item的个数视新特性的页数决定,我这里有3页,就设置成3
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1;}- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return 3;}*最后为每一个cell添加图片
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { TBNewFeatureCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; NSString *imageName = [NSString stringWithFormat:@"new_feature_%ld",indexPath.row + 1]; cell.image = [UIImage imageNamed:imageName]; return cell;}效果如下:
*附上TBNewFeatureCell的代码:
TBNewFeatureCell.h
#import <UIKit/UIKit.h>@interface TBNewFeatureCell : UICollectionViewCell@property (nonatomic,strong) UIImage *image;@endTBNewFeatureCell.m
#import "TBNewFeatureCell.h"@interface TBNewFeatureCell ()@property (nonatomic, weak) UIImageView *imageView;@end@implementation TBNewFeatureCell-(UIImageView *)imageView{ if (_imageView == nil) { UIImageView *imageV = [[UIImageView alloc] initWithFrame:self.bounds]; imageV.image = _image; _imageView = imageV; [self.contentView addSubview:imageV]; } return _imageView;}-(void)setImage:(UIImage *)image{ _image = image; self.imageView.image = image;}@end
0 0
- 课后族项目实战(2)-新特性的实现(使用UICollectionView)
- 利用UICollectionView实现"新特性"功能demo
- UICollectionView新特性
- 新特性之UICollectionView
- [IOS开发]新控件,新特性 UICollectionView(2)
- iOS项目开发实战——使用UICollectionView实现瀑布流
- iOS项目开发实战——实现UICollectionView的动态增加Cell与Section
- 猫猫学iOS 之微博项目实战(7)程序启动新特性用UICollectionViewController实现
- AJ学IOS 之微博项目实战(7)程序启动新特性用UICollectionViewController实现
- 使用UICollectionView写公司的项目
- 关于不用nib实现UICollectionView的使用
- Portal新特性实战 - 使用 Ajax 和 WebSphere Portal
- 项目新特性页面的处理
- 手把手教你使用UICollectionView写公司的项目
- 手把手教你使用UICollectionView写公司的项目
- Java7新特性--实战篇
- IOS6- UICollectionView的使用
- ios UICollectionView的使用
- IOS 键盘弹出遮挡输入框使view上移
- 美国网络安全战略调整与中美新型大国关系的构建
- 如何在web.xml里配置spring容器
- Java web 学习
- Swift - 类的继承 & 访问权限
- 课后族项目实战(2)-新特性的实现(使用UICollectionView)
- 字符型常量
- [Android 解决 “'default' is not a best match for any device/locale ]
- java ArrayList数据对象按排序值大小倒叙排序
- android之旅25 内容提供者与内容观察者
- C++编程练习——用递归法将一个整数N转换成字符串
- C语言数据结构——顺序表
- 从今天起,坚持写博客
- break和continue