uipickerview循环控件的横屏和竖屏的问题

Android横屏竖屏切换的问题
一、禁止横竖屏转换
Android横竖屏切换在手机开发中比较常见,很多软件在开发过程中为了避免横竖屏切换时引发不必要的麻烦,通常禁止掉横竖屏的切换,
通过在AndroidManifest.xml中设置activity中的android:screenOrientation属性值来实现。
比如下列设置
android:screenOrientation="portrait"
则无论手机如何变动,拥有这个属性的activity都将是竖屏显示。
android:screenOrientation="landscape",为横屏显示。
上述修改也可以在Java代码中通过类似如下代码来设置
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
另外,android中每次屏幕的切换动会重启Activity,所以应该在Activity销毁前保存当前活动的状态,在Activity再次Create的时候载入配置,那样,进行中的游戏就不会自动重启了!
二、横竖屏切换
如果要让软件在横竖屏之间切换,由于横竖屏的高宽会发生转换,有可能会要求不同的布局。可以通过以下两种方法来切换布局:
1)在res目录下建立layout-land和layout-port目录,相应的layout文件名不变,比如main.xml。layout-land是横屏的layout,layout-port是竖屏的layout,其他的不用管,横竖屏切换时程序为调用Activity的onCreate方法,从而加载相应的布局。
2)假如布局资源不按照如上设置,则可以通过java代码来判断当前是横屏还是竖屏然后来加载相应的xml布局文件。因为当屏幕变为横屏的时候,系统会重新呼叫当前Activity的onCreate方法,你可以把以下方法放在你的onCreate中来检查当前的方向,然后可以让你的setContentView来载入不同的layout xml。
if(this.getResources().getConfiguration().orientation==Configuration.ORIENTATION_LANDSCAPE)
Log.i("info", "landscape"); //
if(this.getResources().getConfiguration().orientation==Configuration.ORIENTATION_PORTRAIT)
Log.i("info", "portrait"); //
三、通过onConfigurationChanged拦截横竖屏变换
按照二的操作,Activity每次横竖屏切换都会重新调用onPause-&
onStop-& onDestory-&
onCreate-&onStart-&onResume,为此涉及到内容和数据的保存和读取,否则转屏之前的内容就会消失了。很多时候这样的结果让程序繁琐,为此Android提供了在manifest中设置android:configChanges属性,从而让Activity不延续上述的重建流程。在Android工程的Mainfest.xml中配置Activity:android:configChanges="keyboardHidden|orientation",横竖屏切换之后就不会去执行OnCreat函数了,而是会去调用onConfigurationChanged()这样就能控制横竖屏的切换了。用户可以在Activity或View的onConfigurationChanged(Configuration
newConfig)函数中获取当前横竖屏参数。至于其调用顺序跟touch时间的传递顺序相似,不过他没有消费事件的概念,会顺次调用到每一个onConfigurationChanged函数。
需要重写Activity的onConfigurationChanged方法。实现方式如下,不需要做太多的内容:
&&&public void
onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
(this.getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_LANDSCAPE) {
&& &// land do
nothing is ok
&& & } else if
(this.getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_PORTRAIT) {
&& &// port do
nothing is ok
需要注意的是,onConfigurationChanged函数中只能获得横竖屏切换后的参数,在该函数中获取不到新的Layout和控件的尺寸位置信息,如果要处理尺寸和位置信息,必须通过消息异步或者延时调用。
四、彻底禁止翻转
当然如果要彻底禁止翻转,可以设置android:screenOrientation的属性为nosensor,如此就可以忽略重力感应带来的麻烦了。不过在模拟器上不管用,在真机上是正确的。
这里提一个小知识,Android模拟器中,快捷键"Ctrl+F11/F12"可以实现转屏
五,自适应转换
如果想让它启动的时候是横屏的话就横屏表示,纵屏的话就纵屏表示,然后手机切换横竖屏就不能用了该怎么解决呢?
首先:在Mainfest.xml中追加
android:screenOrientation="sensor"
android:configChanges="orientation|keyboardHidden"
这两个属性。
第二步:取得屏幕的长和宽,进行比较设置横竖屏的变量。
Display&display&=&getWindowManager().getDefaultDisplay();&&
int&width&=&display.getWidth();&&
int&height&=&display.getHeight();&&
if&(width&&&height)&{&&
&&&&orientation&=&ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;&&//横屏
}&else&{&&
&&&&orientation&=&ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;&&//竖屏
第三步:在onConfigurationChanged()函数中追加this.setRequestedOrientation(orientation)就行了
public&void&onConfigurationChanged(Configuration&newConfig)&{&&
&&&&super.onConfigurationChanged(newConfig);&&
&&&&this.setRequestedOrientation(orientation);&&
但是这样的话你切到别的画面的时候再回到原画面,它就仍然是横的或者是纵的。怎么让它从别的屏幕回来后,又重新横竖屏布局呢?
只要在OnResume()中在设定下就行了。但是这个只支持横竖屏只有一个layout的。横竖屏分别对应layout的还不知道该怎么解决。
protected&void&onResume()&{&&
&&&&orientation&=&ActivityInfo.SCREEN_ORIENTATION_USER;&&
&&&&this.setRequestedOrientation(orientation);&&
&&&&Display&display&=&getWindowManager().getDefaultDisplay();&&
&&&&int&width&=&display.getWidth();&&
&&&&int&height&=&display.getHeight();&&
&&&&if&(width&&&height)&{&&
&&&&&&&&orientation&=&ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;&&
&&&&}&else&{&&
10. &&&&&&&&orientation&=&ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;&&
11. &&&&}&&
12. &&&&super.onResume();&&
总之,对于横竖屏切换的问题,统计了下,大家的解决办法是: ①不理会。。
②只竖屏显示(android:screenOrientation="portrait")
只横屏显示(android:screenOrientation="landscape")③简单的防止重载:
在 AndroidManifest.xml中加入:android:configChanges="orientation|keyboardHidden"
在activity中重载onConfigurationChanged事件
void onConfigurationChanged(Configuration config) {
super.onConfigurationChanged(config);
}④横竖屏分别布局
横竖屏分别布局的方法是:
在res下新建
layout-land
layout-port
然后把layout中的xml文件分别考到以上目录,修改布局就可以了代码中不做任何更改。
在 AndroidManifest.xml文件中的
主Activity中加入
android:configChanges="orientation|keyboardHidden"
然后在主Activity中的onConfigurationChanged加入
public void onConfigurationChanged(Configuration config) {
super.onConfigurationChanged(config);
if (config.orientation == Configuration.ORIENTATION_PORTRAIT)
setContentView(R.layout.main); //布局
tv = (TextView) findViewById(R.id.EditText01);
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE)
setContentView(R.layout.main); //布局
tv = (TextView) findViewById(R.id.EditText01);
七、示例详细步骤
第一步:获得许可
需要在中添加相应许可
第二步:根据不同的目标,针对Activity进行设置
目标1:屏蔽横竖屏的切换
步骤:为Activity设置一个默认的屏幕方向
方法如下:
在AndroidManifest.xml中找到该Activity
添加代码:
android:name=".ActivityName"
android:screenOrientation="landscape"
&设置Activity的默认方向为“横向”此处的screenOrientation有如下选项:
==================================================================
= unspecified
默认值,由系统判断状态自动切换
= landscape
= portrait
用户当前设置的orientation值
下一个要显示的Activity的orientation值
使用传感器
传感器的方向
= nosensor
不使用传感器
基本等同于unspecified
==================================================================
目标2:防止Activity的销毁
步骤:为Activity设置configChanges属性
在AndroidManifest.xml中找到该Activity
添加代码:
android:name=".ActivityName"
android:configChanges="orientation|keyboardHidden"
&此处的configChanges有如下选项:
==================================================================
= orientation
屏幕在纵向和横向间旋转
= keyboardHidden
键盘显示或隐藏 = fontScale
用户变更了首选的字体大小
用户选择了不同的语言设定
= keyboard
键盘类型变更,例如手机从12键盘切换到全键盘
= touchscreen或navigation
键盘或导航方式变化,一般不会发生这样的事件
==================================================================
如果需要多个选项
此处注意:如果是在实体机上测试横竖屏切换
需要orientation选项
【重点】如果要使得程序可以在Android模拟器上测试
需要写orientation|keyboardHidden如果缺少了keyboardHidden选项
不能防止Activity的销毁
并且在之后提到的onConfigurationChanged事件中
只能捕获竖屏变横屏的事件
不能捕获横屏变竖屏
目标3:捕获横竖屏切换的事件
步骤:在Activity中(ActivityName.java)重写onConfigurationChanged事件
public void onConfigurationChanged(Configuration newConfig) {
// TODO Auto-generated method stub
super.onConfigurationChanged(newConfig);
switch (newConfig.orientation)
//更改为LANDSCAPE
case (Configuration.ORIENTATION_LANDSCAPE):
//如果转换为横向屏时,有要做的事,请写在这里
//更改为PORTRAIT
case (Configuration.ORIENTATION_PORTRAIT):
//如果转换为竖向屏时,有要做的事,请写在这里
八、备注:
1、不设置Activity的android:configChanges时,切屏会重新调用各个生命周期,切横屏时会执行一次,切竖屏时会执行两次
2、设置Activity的android:configChanges="orientation"时,切屏还是会重新调用各个生命周期,切横、竖屏时只会执行一次
3、设置Activity的android:configChanges="orientation|keyboardHidden"时,切屏不会重新调用各个生命周期,只会执行onConfigurationChanged方法
转自网络,自己整合整理。非利益驱使,写于新浪只为便于自己查阅相关资料。感谢各位贡献者!
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。iOS开发入门之UIPickerView控件的简单使用_Linux编程_Linux公社-Linux系统门户网站
你好,游客
iOS开发入门之UIPickerView控件的简单使用
来源:blog.csdn.net/totogo2010&
作者:totogo2010
UIPickerView控件在给用户选择某些特定的数据时经常使用到,这里演示一个简单的选择数据,显示在UITextField输入框里,把UIPickerView作为输入View,用Toolbar作为选定数据的按钮。和其他UITableView控件相似,UIPickerView也需要数据源。
我们要实现的效果如下:
下面开始使用的步骤。
1、打开XCode 4.3.2,新建一个Single View Application ,命名为PickerViewDemo,Company Identifier 为:com.rongfzh.yc
2、拖放控件
2.1、拖放一个UIPickerView,放置在View的最下方
2.2、拖放一个Toolbar控件,放置在View的外面,让它不属于View的子控件,并把item命名为“完成”,效果如下:
2.3 放置一个Flexible Space Bar Button Item 撑开&
2.4 &放一个UITextField,用来显示选择的数据
相关资讯 & & &
& (03/31/:38)
& (01/23/:41)
& (12/24/:04)
& (03/24/:43)
& (01/20/:53)
& (12/17/:41)
图片资讯 & & &
   同意评论声明
   发表
尊重网上道德,遵守中华人民共和国的各项有关法律法规
承担一切因您的行为而直接或间接导致的民事或刑事法律责任
本站管理人员有权保留或删除其管辖留言中的任意内容
本站有权在网站内转载或引用您的评论
参与本评论即表明您已经阅读并接受上述条款iOS开发UI篇—自定义瀑布流控件(蘑菇街数据刷新操作) - 文顶顶 - 博客园
iOS开发UI篇&自定义瀑布流控件(蘑菇街数据刷新操作)
一、简单说明
使用数据刷新框架:
该框架提供了两种刷新的方法,一个是使用block回调(存在循环引用问题,_ _weak),一个是使用调用。
问题:在进行下拉刷新之前,应该要清空之前的所有数据(在刷新数据这个方法中)。
移除正在显示的cell:
(1)把字典中的所有的值,都从屏幕上移除
(2)清除字典中的所有元素
(3)清除cell的frame,每个位置的cell的frame都要重新计算
(4)清除可复用的缓存池。
  该部分的代码如下:
YYWaterflowView.m
Created by apple on 14-7-29.
Copyright (c) 2014年 wendingding. All rights reserved.
9 #import "YYWaterflowView.h"
10 #import "YYWaterflowViewCell.h"
11 #define YYWaterflowViewDefaultNumberOfClunms
12 #define YYWaterflowViewDefaultCellH
13 #define YYWaterflowViewDefaultMargin 10
15 @interface YYWaterflowView()
所有cell的frame数据
19 @property(nonatomic,strong)NSMutableArray *cellF
正在展示的cell
23 @property(nonatomic,strong)NSMutableDictionary
*displayingC
缓存池(使用SET)
27 @property(nonatomic,strong)NSMutableSet *reusableC
30 @implementation YYWaterflowView
32 #pragma mark-懒加载
33 -(NSMutableArray *)cellFrames
if (_cellFrames==nil) {
_cellFrames=[NSMutableArray array];
return _cellF
41 -(NSMutableDictionary *)displayingCells
if (_displayingCells==nil) {
_displayingCells=[NSMutableDictionary dictionary];
return _displayingC
49 -(NSMutableSet *)reusableCells
if (_reusableCells==nil) {
_reusableCells=[NSMutableSet set];
return _reusableC
57 - (id)initWithFrame:(CGRect)frame
self = [super initWithFrame:frame];
if (self) {
65 -(void)willMoveToSuperview:(UIView *)newSuperview
[self reloadData];
70 #pragma mark-公共方法
cell的宽度
74 -(CGFloat)cellWidth
//cell的列数
int numberOfColumns=[self numberOfColumns];
CGFloat leftM=[self marginForType:YYWaterflowViewMarginTypeLeft];
CGFloat rightM=[self marginForType:YYWaterflowViewMarginTypeRight];
CGFloat columnM=[self marginForType:YYWaterflowViewMarginTypeColumn];
return (self.frame.size.width-leftM-rightM-(numberOfColumns-1)*columnM)/numberOfC
1.计算每个cell的frame
88 -(void)reloadData
(1)把字典中的所有的值,都从屏幕上移除
(2)清除字典中的所有元素
(3)清除cell的frame,每个位置的cell的frame都要重新计算
(4)清除可复用的缓存池。
[self.displayingCells.allValues makeObjectsPerformSelector:@selector(removeFromSuperview)];
[self.displayingCells removeAllObjects];
[self.cellFrames removeAllObjects];
[self.reusableCells removeAllObjects];
//cell的总数是多少
int numberOfCells=[self.dadaSource numberOfCellsInWaterflowView:self];
//cell的列数
int numberOfColumns=[self numberOfColumns];
CGFloat leftM=[self marginForType:YYWaterflowViewMarginTypeLeft];
CGFloat columnM=[self marginForType:YYWaterflowViewMarginTypeColumn];
CGFloat topM=[self marginForType:YYWaterflowViewMarginTypeTop];
CGFloat rowM=[self marginForType:YYWaterflowViewMarginTypeRow];
CGFloat bottomM=[self marginForType:YYWaterflowViewMarginTypeBottom];
//(1)cell的宽度
//cell的宽度=(整个view的宽度-左边的间距-右边的间距-(列数-1)X每列之间的间距)/总列数
CGFloat cellW=(self.frame.size.width-leftM-rightM-(numberOfColumns-1)*columnM)/numberOfC
CGFloat cellW=[self cellWidth];
//用一个C语言的数组来存放所有列的最大的Y值
CGFloat maxYOfColumns[numberOfColumns];
for (int i=0; i&numberOfC i++) {
//初始化数组的数值全部为0
maxYOfColumns[i]=0.0;
//计算每个cell的fram
for (int i=0; i&numberOfC i++) {
//(2)cell的高度
//询问代理i位置的高度
CGFloat cellH=[self heightAtIndex:i];
//cell处在第几列(最短的一列)
NSUInteger cellAtColumn=0;
//cell所处那列的最大的Y值(当前最短的那一列的最大的Y值)
//默认设置最短的一列为第一列(优化性能)
CGFloat maxYOfCellAtColumn=maxYOfColumns[cellAtColumn];
//求出最短的那一列
for (int j=0; j&numberOfC j++) {
if (maxYOfColumns[j]&maxYOfCellAtColumn) {
cellAtColumn=j;
maxYOfCellAtColumn=maxYOfColumns[j];
//(3)cell的位置(X,Y)
//cell的X=左边的间距+列号*(cell的宽度+每列之间的间距)
CGFloat cellX=leftM+cellAtColumn*(cellW +columnM);
//cell的Y,先设定为0
CGFloat cellY=0;
if (maxYOfCellAtColumn==0.0) {//首行
cellY=topM;
cellY=maxYOfCellAtColumn+rowM;
//设置cell的frame并添加到数组中
CGRect cellFrame=CGRectMake(cellX, cellY, cellW, cellH);
[self.cellFrames addObject:[NSValue valueWithCGRect:cellFrame]];
//更新最短那一列的最大的Y值
maxYOfColumns[cellAtColumn]=CGRectGetMaxY(cellFrame);
//设置contentSize
CGFloat contentH=maxYOfColumns[0];
for (int i=1; i&numberOfC i++) {
if (maxYOfColumns[i]&contentH) {
contentH=maxYOfColumns[i];
contentH += bottomM;
self.contentSize=CGSizeMake(0, contentH);
当UIScrollView滚动的时候也会调用这个方法
185 -(void)layoutSubviews
[super layoutSubviews];
//向数据源索要对应位置的cell
NSUInteger numberOfCells=self.cellFrames.
for (int i=0; i&numberOfC i++) {
//取出i位置的frame,注意转换
CGRect cellFrame=[self.cellFrames[i] CGRectValue];
//优先从字典中取出i位置的cell
YYWaterflowViewCell *cell=self.displayingCells[@(i)];
//判断i位置对应的frame在不在屏幕上(能否看见)
if ([self isInScreen:cellFrame]) {//在屏幕上
if (cell==nil) {
cell= [self.dadaSource waterflowView:self cellAtIndex:i];
cell.frame=cellF
[self addSubview:cell];
//存放在字典中
self.displayingCells[@(i)]=
}else //不在屏幕上
if (cell) {
//从scrollView和字典中删除
[cell removeFromSuperview];
[self.displayingCells removeObjectForKey:@(i)];
//存放进缓存池
[self.reusableCells addObject:cell];
NSLog(@"%d",self.subviews.count);
225 -(id)dequeueReusableCellWithIdentifier:(NSString *)identifier
__block YYWaterflowViewCell *reusableCell=
[self.reusableCells enumerateObjectsUsingBlock:^(YYWaterflowViewCell *cell, BOOL *stop) {
if ([cell.identifier isEqualToString:identifier]) {
reusableCell=
*stop=YES;
if (reusableCell) {//从缓存池中移除(已经用掉了)
[self.reusableCells removeObject:reusableCell];
return reusableC
241 #pragma mark cell的事件处理
242 -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
//如果没有点击事件的代理方法,那么就直接返回
if (![self.delegate respondsToSelector:@selector(waterflowView:didSelectAtIndex:)])
//获得手指在屏幕上点击的触摸点
UITouch *touch=[touches anyObject];
CGPoint point1=[touch locationInView:touch.view];
CGPoint point=[touch locationInView:self];
NSLog(@"%@--%@",NSStringFromCGPoint(point),NSStringFromCGPoint(point1));
__block NSNumber *selectIndex=
[self.displayingCells enumerateKeysAndObjectsUsingBlock:^(id key, YYWaterflowViewCell *cell, BOOL *stop) {
if (CGRectContainsPoint(cell.frame, point)) {
selectIndex=
*stop=YES;
if (selectIndex) {
//需要转换
[self.delegate waterflowView:self didSelectAtIndex:selectIndex.unsignedIntegerValue];
267 #pragma mark-私有方法
判断一个人cell的frame有没有显示在屏幕上
271 -(BOOL)isInScreen:(CGRect)frame
return (CGRectGetMaxY(frame)&self.contentOffset.y)&&(CGRectGetMaxY(frame)&self.contentOffset.y+self.frame.size.height);
return (CGRectGetMaxY(frame) & self.contentOffset.y) &&
(CGRectGetMinY(frame) & self.contentOffset.y + self.frame.size.height);
278 -(CGFloat)marginForType:(YYWaterflowViewMarginType)type
if ([self.delegate respondsToSelector:@selector(waterflowView:marginForType:)]) {
[self.delegate waterflowView:self marginForType:type];
return YYWaterflowViewDefaultM
288 -(NSUInteger)numberOfColumns
if ([self.dadaSource respondsToSelector:@selector(numberOfColumnsInWaterflowView:)]) {
return [self.dadaSource numberOfColumnsInWaterflowView:self];
YYWaterflowViewDefaultNumberOfC
298 -(CGFloat)heightAtIndex:(NSUInteger)index
if ([self.delegate respondsToSelector:@selector(waterflowView:heightAtIndex:)]) {
return [self.delegate waterflowView:self heightAtIndex:index];
return YYWaterflowViewDefaultCellH;
二、刷新操作
&  刷新操作的代码设计:
YYShopViewController.m
Created by apple on 14-7-31.
Copyright (c) 2014年 wendingding. All rights reserved.
9 #import "YYShopViewController.h"
10 #import "YYWaterflowView.h"
11 #import "YYWaterflowViewCell.h"
12 #import "YYShop.h"
13 #import "YYShopCell.h"
14 #import "MJExtension.h"
15 #import "MJRefresh.h"
17 @interface YYShopViewController ()&YYWaterflowViewDataSource,YYWaterflowViewDelegate&
18 @property(nonatomic,strong)NSMutableArray *
19 @property(nonatomic,strong)YYWaterflowView *waterflowV
22 @implementation YYShopViewController
24 #pragma mark-懒加载
25 -(NSMutableArray *)shops
if (_shops==nil) {
_shops=[NSMutableArray array];
32 - (void)viewDidLoad
[super viewDidLoad];
//1.初始化数据
NSArray *newShop=[YYShop objectArrayWithFilename:@"2.plist"];
[self.shops addObjectsFromArray:newShop];
//2.创建一个瀑布流
YYWaterflowView *waterflow=[[YYWaterflowView alloc]init];
waterflow.autoresizingMask=UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleW
waterflow.frame=self.view.
waterflow.delegate=
waterflow.dadaSource=
[self.view addSubview:waterflow];
self.waterflowView=
//3.实现数据的刷新
[waterflow addFooterWithCallback:^{
NSLog(@"上拉数据刷新");
[waterflow addHeaderWithCallback:^{
NSLog(@"下拉数据刷新");
[waterflow addHeaderWithTarget:self action:@selector(loadNewShops)];
[waterflow addFooterWithTarget:self action:@selector(loadMoreShops)];
63 -(void)loadNewShops
//模拟,只执行一次刷新操作
static dispatch_once_t onceT
dispatch_once(&onceToken, ^{
//加载1.plist文件
NSArray *newShop=[YYShop objectArrayWithFilename:@"1.plist"];
[self.shops insertObjects:newShop atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, newShop.count)]];
//模拟网络延迟,2.0秒钟之后执行
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//刷新数据
[self.waterflowView reloadData];
//停止刷新
[self.waterflowView headerEndRefreshing];
83 -(void)loadMoreShops
static dispatch_once_t onceT
dispatch_once(&onceToken, ^{
//加载1.plist文件
NSArray *newShop=[YYShop objectArrayWithFilename:@"3.plist"];
[self.shops addObjectsFromArray:newShop];
//模拟网络延迟,2.0秒钟之后执行
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//刷新数据
[self.waterflowView reloadData];
//停止刷新
[self.waterflowView footerEndRefreshing];
103 #pragma mark-数据源方法
104 -(NSUInteger)numberOfCellsInWaterflowView:(YYWaterflowView *)waterflowView
return self.shops.
108 -(NSUInteger)numberOfColumnsInWaterflowView:(YYWaterflowView *)waterflowView
112 -(YYWaterflowViewCell *)waterflowView:(YYWaterflowView *)waterflowView cellAtIndex:(NSUInteger)index
YYShopCell *cell=[YYShopCell cellWithwaterflowView:waterflowView];
cell.shop=self.shops[index];
120 #pragma mark-代理方法
121 -(CGFloat)waterflowView:(YYWaterflowView *)waterflowView heightAtIndex:(NSUInteger)index
YYShop *shop=self.shops[index];
//根据Cell的宽度和图片的宽高比 算出cell的高度
return waterflowView.cellWidth*shop.h/shop.w;
128 -(void)waterflowView:(YYWaterflowView *)waterflowView didSelectAtIndex:(NSUInteger)index
NSLog(@"点击了第%d个cell",index);
实现的刷新效果:
  & &&& & &
三、竖屏和横屏调整
设置横屏和竖屏。
屏幕旋转完毕会调用下面的方法。
因为scrollView的宽度是固定的,没有改变。
设置view的宽度和高度可以跟随者父控件自动拉伸。(在iPad开发中会将常用到)
随笔 - 275
评论 - 395

我要回帖

更多关于 ui.datepicker.js 的文章

 

随机推荐