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 一.要求 要求完成下面一个小的应用程序. 二.一步步对代码进行优化 注意:在开发过程中,优化的过程是一步一步进行的.(如果一个人要吃五个包子才能吃饱,那么他 ...
随机推荐
- Android组件间交互
四大组件相信大家都不陌生了吧,今天咱们就组件间通信做个说明: 首先: 主要今天的目的是为了说明Android 提供的一个ResultReceiver类,这个类相信大家都不陌生吧>?但是你们层深入 ...
- windows系统调用 semaphore信号量
#include "iostream" #include "windows.h" #include "cstring" using name ...
- Mysql 语句中对关键字进行转义的方式
在SQLserver中, 对列名表名库名Owner进行转义使用的是[ ] 这个我在其他文章中讲过 ,而且这是一个很好的习惯! 同理 在MySql中 也建议对表名等进行转移 使用的方式是 `` 就 ...
- 搭建android开发环境
任何一个程序的开端都要从搭建开发环境开始,这样你就可以进行实战练习了,并且搭建完后即快速来一个项目HelloWorld, 哈哈,话不多说了,进入正题 android环境的安装主要分3步骤: 1.下载和 ...
- [attribute] 匹配包含给定属性的元素
描述: 查找所有含有 id 属性的 div 元素 HTML 代码: <div> <p>Hello!</p> </div> <div id=&quo ...
- apache+php+mysql的配置(转载)
windows: 按http://jingyan.baidu.com/article/fcb5aff797ec41edaa4a71c4.html的安装 按http://www.jb51.net/art ...
- CentOS配置SSH免密码登录后,仍提示输入密码
CentOS配置SSH无密码登录需要3步: 生成公钥和私钥 导入公钥到认证文件,更改权限 测试 1.生成公钥和私钥 ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa 默 ...
- inotify+rsync目录实时同步
两台linux服务器系统CentOS7 一台Apache IP:192.168.155.130(发布文件服务器,也可以叫rsync客户端) 一台nginx IP:192.168.155.131(同步镜 ...
- 微信OAuth2.0网页受权php
www.MyException.Cn 网友分享于:2014-01-19 浏览:2504次 微信OAuth2.0网页授权php示例 1.配置授权回调页面域名,如 www.aaa.com 2.模拟公众号的 ...
- dbutils中实现数据的增删改查的方法,反射常用的方法,绝对路径的写法(杂记)
jsp的三个指令为:page,include,taglib... 建立一个jsp文件,建立起绝对路径,使用时,其他jsp文件导入即可 导入方法:<%@ include file="/c ...