iOS开发UI篇—无限轮播(循环利用)
iOS开发UI篇—无限轮播(循环利用)
一、无限轮播
1.简单说明






//
// YYViewController.m
// 07-无限滚动(循环利用)
//
// Created by apple on 14-8-3.
// Copyright (c) 2014年 yangyong. All rights reserved.
// #import "YYViewController.h" @interface YYViewController ()<UICollectionViewDataSource,UICollectionViewDelegate>
@property (weak, nonatomic) IBOutlet UICollectionView *collectinView; @end @implementation YYViewController - (void)viewDidLoad
{
[super viewDidLoad];
21 //注册cell
22 static NSString *ID=@"cell";
23 [self.collectinView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:ID]; } #pragma mark- UICollectionViewDataSource
//一共多少组,默认为1组
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return ;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return ;
} -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *ID=@"cell";
UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
cell.backgroundColor=YYRandomColor;
return cell;
} #pragma mark-UICollectionViewDelegate
@end



YYimageCell.h文件
//
// YYimageCell.h
// 07-无限滚动(循环利用)
//
// Created by apple on 14-8-3.
// Copyright (c) 2014年 yangyong. All rights reserved.
// #import <UIKit/UIKit.h> @interface YYimageCell : UICollectionViewCell
@property(nonatomic,copy)NSString *icon;
@end
YYimageCell.m文件
//
// YYimageCell.m
// 07-无限滚动(循环利用)
//
// Created by apple on 14-8-3.
// Copyright (c) 2014年 yangyong. All rights reserved.
// #import "YYimageCell.h" @interface YYimageCell ()
@property(nonatomic,strong)UIImageView *imageView;
@end
@implementation YYimageCell - (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) { UIImageView *imageView=[[UIImageView alloc]init];
[self addSubview:imageView];
self.imageView=imageView;
}
return self;
} -(void)setIcon:(NSString *)icon
{
_icon=[icon copy];
self.imageView.image=[UIImage imageNamed:icon];
} -(void)layoutSubviews
{
[super layoutSubviews];
self.imageView.frame=self.bounds;
} @end
YYViewController.m文件
//
// YYViewController.m
// 07-无限滚动(循环利用)
//
// Created by apple on 14-8-3.
// Copyright (c) 2014年 yangyong. All rights reserved.
// #import "YYViewController.h"
#import "YYimageCell.h" #define YYCell @"cell" @interface YYViewController ()<UICollectionViewDataSource,UICollectionViewDelegate>
@property (weak, nonatomic) IBOutlet UICollectionView *collectinView; @end @implementation YYViewController - (void)viewDidLoad
{
[super viewDidLoad];
//注册cell
// static NSString *ID=@"cell";
[self.collectinView registerClass:[YYimageCell class] forCellWithReuseIdentifier:YYCell]; } #pragma mark- UICollectionViewDataSource
//一共多少组,默认为1组
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return ;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return ;
} -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
// static NSString *ID=@"cell";
YYimageCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:YYCell forIndexPath:indexPath];
cell.backgroundColor=YYRandomColor;
NSLog(@"%p,%d",cell,indexPath.item);
cell.icon=[NSString stringWithFormat:@"minion_%02d",indexPath.item+];
return cell;
} #pragma mark-UICollectionViewDelegate
@end





iOS开发UI篇—无限轮播(循环利用)的更多相关文章
- iOS开发UI篇—无限轮播(循环展示)
iOS开发UI篇—无限轮播(循环展示) 一.简单说明 之前的程序还存在一个问题,那就是不能循环展示,因为plist文件中只有五个数组,因此第一个和最后一个之后就没有了,下面介绍处理这种循环展示问题的小 ...
- iOS开发UI篇—无限轮播(功能完善)
iOS开发UI篇—无限轮播(功能完善) 一.自动滚动 添加并设置一个定时器,每个2.0秒,就跳转到下一条. 获取当前正在展示的位置. [self addNSTimer]; } -(void)addNS ...
- iOS开发UI篇—无限轮播(新闻数据展示)
iOS开发UI篇—无限轮播(新闻数据展示) 一.实现效果 二.实现步骤 1.前期准备 (1)导入数据转模型的第三方框架MJExtension (2)向项目中添加保存有“新闻”数据的pli ...
- iOS开发UI篇—UIScrollView控件实现图片轮播
iOS开发UI篇—UIScrollView控件实现图片轮播 一.实现效果 实现图片的自动轮播 二.实现代码 storyboard中布局 代码: #import "YYV ...
- 【转】 iOS开发UI篇—UIScrollView控件实现图片轮播
原文:http://www.cnblogs.com/wendingding/p/3763527.html iOS开发UI篇—UIScrollView控件实现图片轮播 一.实现效果 实现图片的自动轮播 ...
- iOS开发UI篇—核心动画(UIView封装动画)
iOS开发UI篇—核心动画(UIView封装动画) 一.UIView动画(首尾) 1.简单说明 UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView将为这些改变提供动画 ...
- iOS开发UI篇—iOS开发中三种简单的动画设置
iOS开发UI篇—iOS开发中三种简单的动画设置 [在ios开发中,动画是廉价的] 一.首尾式动画 代码示例: // beginAnimations表示此后的代码要“参与到”动画中 [UIView b ...
- iOS开发UI篇—九宫格坐标计算
iOS开发UI篇—九宫格坐标计算 一.要求 完成下面的布局 二.分析 寻找左边的规律,每一个uiview的x坐标和y坐标. 三.实现思路 (1)明确每一块用得是什么view (2)明确每个view之间 ...
- iOS开发UI篇—从代码的逐步优化看MVC
iOS开发UI篇—从代码的逐步优化看MVC 一.要求 要求完成下面一个小的应用程序. 二.一步步对代码进行优化 注意:在开发过程中,优化的过程是一步一步进行的.(如果一个人要吃五个包子才能吃饱,那么他 ...
随机推荐
- java mybatis 动态sql
//-------------------------------查询-------------------------------------// <sql id="cmsGuest ...
- FRM-40831 出现截断
此问题还有一种情况: 在form搜索界面使用时间范围搜索时遇到的 当在PRE-QUERY中调用如下查询时,如果CUX_SUM.PERIOD_NAME的字段长度要设置的长一些,个人建议是前面2个字段的2 ...
- 14. 星际争霸之php设计模式--状态模式
题记==============================================================================本php设计模式专辑来源于博客(jymo ...
- SSH 无密码远程执行脚本
ssh无密码登录及远程执行脚本要使用公钥与私钥.linux下可以用用ssh-keygen生成公钥/私钥对,下面我以CentOS7为例. 测试环境:机器A(10.0.224.80):机器B(192.16 ...
- [课程设计]Scrum 2.2 多鱼点餐系统开发进度(下单页面修复&美化)
[课程设计]Scrum 2.2 多鱼点餐系统开发进度 1.团队名称:重案组 2.团队目标:长期经营,积累客户充分准备,伺机而行 3.团队口号:矢志不渝,追求完美 4.团队选题:餐厅到店点餐系统WEB ...
- Locality Sensitive Hash 局部敏感哈希
Locality Sensitive Hash是一种常见的用于处理高维向量的索引办法.与其它基于Tree的数据结构,诸如KD-Tree.SR-Tree相比,它较好地克服了Curse of Dimens ...
- vs2013-tfs-疑问之版本控制器路径有双引号解决办法
问题描述: 最近项目:“****”展示交易平台 ,所以版本控制器路径为: 导致生成解决方案提示:路径有问题 解决办法: 1.直接在版本控制器重命名是不支持的,需要安装: Visual Studio ...
- 【Redis】Redis的基本安装及使用
在Linux上安装Redis Redis的安装很简单.基本上是下载.解压.运行安装脚本.我用的Redis版本是3.2.1. [nicchagil@localhost app]$ wget -q htt ...
- [问题2015S11] 复旦高等代数 II(14级)每周一题(第十二教学周)
[问题2015S11] 证明: 任一复方阵都相似于一个复对称阵. 举例说明: 存在实方阵, 它不相似于实对称阵. 问题解答请在以下网址下载:http://pan.baidu.com/share/ho ...
- hadoop2.0初识1.0
1.给普通用户设置sudo权限 编辑:[root@life-hadoop /]# nano /etc/sudoers 在文件头部加入:yanglin ALL=(root)NOPASSWD:ALL 保存 ...