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 一.要求 要求完成下面一个小的应用程序. 二.一步步对代码进行优化 注意:在开发过程中,优化的过程是一步一步进行的.(如果一个人要吃五个包子才能吃饱,那么他 ...
随机推荐
- Jmeter中察看结果树中的响应数据,中文显示乱码问题处理
打开apache-jmeter-xxx\bin\jmeter.properties文件,搜索"encoding"关键字,找到如下配置: # The encoding to be u ...
- C# UDP 连接通信 简单示例
Udp.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using S ...
- geckodriver v0.11.0 github上下载的
从 https://github.com/mozilla/geckodriver/releases 下载的.家里下载不了,selenium 3.0.1 + python 2.7.10 + firefo ...
- ubuntu 15.04 联网提示:wifi已通过硬件开关禁用
执行以下命令: echo "options asus_nb_wmi wapf=4"| sudo tee /etc/modprobe.d/asus_nb_wmi.conf 重启
- OAuth2.0概述
OAuth2.0较1.0相比,整个授权验证流程更简单更安全,也是未来最主要的用户身份验证和授权方式. 关于OAuth2.0协议的授权流程可以参考下面的流程图,其中Client指第三方应用,Resour ...
- 机器学习实战-边学边读python代码(4)
程序2-4 分类器针对约会网站的测试代码(4) def datingClassTest():hoRatio = 0.10 //将文件读入内存矩阵datingDataMat,datingLabels = ...
- JQuery 层次选择器
<!DOCTYPE HTML> <html> <head> <title> 使用jQuery层次选择器 </title> <scrip ...
- linux下tftp使用(转一些命令)
转载于:http://cache.baiducontent.com/c?m=9d78d513d99d1af31fa7837e7c5083205b4380122ba6d1020ba5843990732c ...
- c/s 与b/s构架
C/S架构是一种比较早的软件架构,主要应用于局域网内.在这之前经历了集中计算模式,随着计算机网络的进步与发展,尤其是可视化工具的应用,出现过两层C/S和三层C/S架构,不过一直很流行也比较经典的是我们 ...
- chrome表单自动填充去掉input黄色背景解决方案
设置css代码如下: input:-webkit-autofill { -webkit-box-shadow: 0 0 0px 1000px white inset; } 参考文章:http://bl ...