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 一.要求 要求完成下面一个小的应用程序. 二.一步步对代码进行优化 注意:在开发过程中,优化的过程是一步一步进行的.(如果一个人要吃五个包子才能吃饱,那么他 ...
随机推荐
- Python介绍、安装、使用
Python介绍.安装.使用 搬运工:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Python语言介绍 说到Python语言,就不得不说一下它的创始人Guido van Rossu ...
- Coursera台大机器学习课程笔记3 – 机器学习的可能性
提纲: 机器学习为什么可能? 引入计算橙球概率问题 通过用Hoeffding's inequality解决上面的问题,并得出PAC的概念,证明采样数据学习到的h的错误率可以和全局一致是PAC的 将得到 ...
- JVM常见配置汇总
堆设置 -Xms:初始堆大小 -Xmx:最大堆大小 -XX:NewSize=n:设置年轻代大小 -XX:NewRatio=n:设置年轻代和年老代的比值.如:为3,表示年轻代与年老代比值为1:3,年轻代 ...
- Azure sdk for python
http://www.oschina.net/translate/python-windows-azure Len 6:17:54 PM __author__ = 'len.li' from azu ...
- [转]MySQL5.6新特性之Multi-Range Read
这几天看到mrr的东西,刚好看到以前我们组的一个小伙的博客,我看挺全的,就转过来了,原博客地址请戳 一 介绍 MySQL 5.6版本提供了很多性能优化的特性,其中之一就是 Multi-Range ...
- 一个注解方式webSocket demo
前段时间在研究websocket.其中遇到了一些bug.这里跟大家分享这过程. 首先介绍一下websocket WebSocket是HTML5的一种新协议,实现了浏览器和服务器的双全工通信,能更好的节 ...
- Web_add_header
如果你发现所有的HTTP send请求都缺少头数据包,在脚本中的开头添加web_add_auto_header(”XXXXX“,”yyyy“);随着web_add_auto_header的添加,你不需 ...
- 循环多次ajax请求
最近在做网页前端,其中有个功能按钮是从数据表格中同时删除多条数据,涉及到循环多次ajax请求 但是老是出现一些请求被忽视的情况,应该是由于for循环在极短时间内被完成,所以第一次请求后的几次请求时,x ...
- runoob
今天学习bootstrap的时候偶然发现http://www.runoob.com/ 这个网站不错,比w3cschool界面要好看,内容要丰富 比较适合新手学习,而且上面的内容比较丰富,不错.
- HDU 5688:2016"百度之星" - 资格赛 Problem D
原文链接:https://www.dreamwings.cn/hdu5688/2650.html Problem D Time Limit: 2000/1000 MS (Java/Others) ...