在做这个tablevew轮播的时候,重要的就是修改frame 和view 的翻转了::::

也是不难的,概要的设计和scroll 轮播是一致的;

首先是 .h 的文件

@interface TableViewShuffling : UIView

@property (nonatomic,strong)NSArray *array;

@end

重要的点在.m 文件中加载了详细的注释

@interface TableViewShuffling ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UITableView *tableView;

@property(nonatomic,strong)NSMutableArray *tableArray;

@end

@implementation TableViewShuffling
@synthesize array = _array;
- (instancetype)initWithFrame:(CGRect)frame{ if ( self = [super initWithFrame:frame]) {
}
return self;
} -(UITableView*)tableView{ if (_tableView == nil) {
/*
_tableView.transform = CGAffineTransformMakeRotation(-M_PI / 2); CGRect tabelRect = CGRectMake(10, 10, self.frame.size.height-20, self.frame.size.width-20);
重点:::
因为table view 翻转 90度角 ,所以frame 设计的时候 宽高 ==互 换===了
*/
CGRect tabelRect = CGRectMake(, , self.frame.size.height-, self.frame.size.width-); _tableView = [[UITableView alloc] initWithFrame:tabelRect style:UITableViewStylePlain];
[self addSubview:self.tableView];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.pagingEnabled = YES; // scrollbar 不显示
//tableview逆时针旋转90度。
_tableView.transform = CGAffineTransformMakeRotation(-M_PI / );
/* _tableView.center = CGPointMake(self.frame.size.width / 2, self.frame.size.height / 2);
重点::: 同样,因为翻转的关系,要把table 重写设置初始位置
*/
_tableView.center = CGPointMake(self.frame.size.width / , self.frame.size.height / );
}
return _tableView;
} -(void)setArray:(NSArray *)array{ NSAssert(array.count != , @"传入的滚动数组是 空的");
_array = array;
[self prepareData];
[self prepareUI];
} -(void)prepareUI{

/*
跳转到 row 1===
*/
[self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow: inSection:] animated:YES scrollPosition:UITableViewScrollPositionTop];
[self.tableView reloadData];
} - (void)prepareData{ self.tableArray = [NSMutableArray new];
// 首位 添加数组最后的元素
[self.tableArray addObject:_array.lastObject];
// 添加数组元素
[self.tableArray addObjectsFromArray:_array];
// 末尾 补充第一个元素
[self.tableArray addObject:_array.firstObject];
} -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
/*
row height 千万分清楚 应该是 width 还是haigh 的值
*/
return self.frame.size.width-;
} -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.tableArray.count;
} - (UITableViewCell *)tableView :( UITableView *)tableView cellForRowAtIndexPath:( NSIndexPath*)indexPath
{
/*
为什么 不要用系统cell,必须自定义??
因为你设置 这个tableShuffling view 高度小的时候,会影响titlelabel 等属性显示不全,因为翻转的时候,他们的位置没有改变
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
// cell顺时针旋转90度
cell.contentView.transform = CGAffineTransformMakeRotation(M_PI / 2);
}
cell.textLabel.text = [NSString stringWithFormat:@"';llkjjjjjjhgfds1234567890-=qwertyuioyuiop[asdfghjkl;zxcvbnm,====%ld",(long)indexPath.row];
cell.textLabel.numberOfLines = 0; cell.contentView.backgroundColor = (UIColor*)self.tableArray[indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell; */ ShufflingCell *cell = [ShufflingCell getCellForTableView:tableView withIdentifier:@"ShufflingCell" andIndexPath:indexPath];
/*
    cell.contentView.transform = CGAffineTransformMakeRotation(M_PI / 2);
table View 翻转了,但是要把 cell 翻转回正常的状态,否则自定义的cell 显示也是翻转的
*/
cell.contentView.transform = CGAffineTransformMakeRotation(M_PI / );
cell.contentView.backgroundColor = (UIColor*)self.tableArray[indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell; } -(void)scrollViewDidScroll:(UIScrollView *)scrollView{ if (scrollView == self.tableView) { //检测移动的位移
if (scrollView.contentOffset.y == (self.tableArray.count-)*(self.frame.size.width-) ) { [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow: inSection:] animated:NO scrollPosition:UITableViewScrollPositionTop]; }else if (scrollView.contentOffset.y == ){ [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:(self.tableArray.count-) inSection:] animated:NO scrollPosition:UITableViewScrollPositionTop]; }else{ // 正常滚动
} }
}

table view 的滚动视图也基本完成,好久没写了,过程有点曲折;

总结下重点:::

  1. frame 翻转前后设置
  2. row Height 的设置
  3. table 翻转后 cell正常显示,一定要翻转回去

外部调用方法:::::

-(void)prepareTableShuffling{

    TableViewShuffling *tableffling = [[TableViewShuffling alloc]initWithFrame:CGRectMake(, , self.view.frame.size.width -, )];
[self.view addSubview:tableffling];;
tableffling.array = self.arr;
}

辛苦的我,今天想早点下班,明天继续……………………

01.轮播图之二 :tableView 轮播的更多相关文章

  1. 01.轮播图之一 :scrollView 轮播

    接触的每个项目,都会用到轮播图的部分,轮播图都写了好多次,用过各种各样的方式写: 这篇总结的博客,我将分为几个篇幅写,希望写完这几篇博客之后,我能总结出自己写这个轮播的优缺和不同之处 scrollvi ...

  2. js原生选项卡(自动播放无缝滚动轮播图)二

    今天分享一下自动播放轮播图,自动播放轮播图是在昨天分享的轮播图的基础上添加了定时器,用定时器控制图片的自动切换,函数中首先封装一个方向的自动播放工能的小函数,这个函数中添加定时器,定时器中可以放向右走 ...

  3. 仿爱奇艺视频,腾讯视频,搜狐视频首页推荐位轮播图(二)之SuperIndicator源码分析

    转载请把头部出处链接和尾部二维码一起转载,本文出自逆流的鱼:http://blog.csdn.net/hejjunlin/article/details/52510431 背景:仿爱奇艺视频,腾讯视频 ...

  4. jQuery轮播图(二)利用构造函数和原型创建对象以实现继承

    本文是在我开始学习JavaScript继承时,对原型继承的一些理解和运用.文中所述的继承方式均是使用js特有的原型链方式,实际上有了ES6的类之后,实现继承的就变得十分简单了,所以这种写法现在也不在推 ...

  5. jquery特效(4)—轮播图②(定时自动轮播)

    周末出去逛完街,就回公司好好地研究代码了,也算是把定时自动轮播程序写出来了,特意说明一下,这次的轮播图是在昨天随笔中jquery特效(3)—轮播图①(手动点击轮播)的基础上写出来的,也就是本次随笔展示 ...

  6. 带轮播图、导航栏、商品的简单html,以及轮播图下边数字随轮播图的改变而改变

    ---恢复内容开始--- 在做这个的时候,最不会的是中间轮播图下边的数字是如何实现转变的,后来加入了jQuery就能实现了. css部分: <style type="text/css& ...

  7. jQuery轮播图(一)轮播实现并封装

    利用面向对象自己动手写了一个封装好的jquery轮播组件,可满足一般需求,不仅使用简单且复用性高. demo:点此预览 代码地址:https://github.com/zsqosos/componen ...

  8. JS轮播图(网易云轮播图)

    JS 轮播图 写在前面 最聪明的人是最不愿浪费时间的人.--但丁 实现功能 图片自动切换 鼠标移入停止自动播放,显示按钮 点击按钮,实现前后翻 鼠标移入小圆圈,可以跳转到对应图片 点击左右两侧图片部分 ...

  9. 01.轮播图之三 : collectionView 轮播

    个人觉得 collection view 做轮播是最方便的,设置下flowlayout 其他不会有很大的变动,没有什么逻辑的代码 let's begin…… 创建自定义的view .h 声明文件 @i ...

随机推荐

  1. JS闭包是什么?

    闭包是js开发惯用的技巧,什么是闭包? 闭包指的是:能够访问另一个函数作用域的变量的函数. 清晰的讲:闭包就是一个函数,这个函数能够访问其他函数的作用域中的变量. function outer(){ ...

  2. 31、[源码]-AOP原理-AnnotationAwareAspectJAutoProxyCreato机

    31.[源码]-AOP原理-AnnotationAwareAspectJAutoProxyCreato机

  3. win32通用控件

    1.标准控件 可以在win32窗口程序中添加资源脚本来给程序添加标准控件: 具体操作为:新建资源脚本    ->在.rc文件中添加控件    ->给控件绑定事件:   常用的标准控件:   ...

  4. 002_Python3 基础语法

    1.注释 实例1: #!/usr/bin/python3 # 第一个注释 print("Hello, Python!")  # 第二个注释   ****************** ...

  5. DOM操作2

    一.API和WebAPI API就是接口,就是通道,负责一个程序和其他软件的沟通,本质是预先定义的函数. Web API是网络应用程序接口.包含了广泛的功能,网络应用通过API接口,可以实现存储服务. ...

  6. css添加了原始滚动条要隐藏滚动条的显示

    // 添加伪类 <style> ::-webkit-scrollbar {display:none} </style> <div style=" width:2 ...

  7. yii2.0 模块的使用

    以高级模板为例 1.复制目录 frontend或backend 为一个新目录pro修改advanced\common\config\bootstrap.php 添加一行,加载刚才的路劲Yii::set ...

  8. QTP安装出现windoes installer不能安装升级修补程序问题

    问题如下: windoes installer不能安装升级修补程序问题 如何解决?还未找到解决方案

  9. NOIP1998提高组 题解报告

    T1 进制位 题目大意:自己看吧 首先让我们来看两个引理: 如果有解,则进制一定为\(n - 1\) 如果有解,则字母一定表示\(0\) 至 \(n - 1\) 的数 证明如下: 因为有 \(n - ...

  10. 什么是vue的全家桶

    vue.js有著名的全家桶系列,包含了vue-router,vuex, vue-resource,再加上构建工具vue-cli,就是一个完整的vue项目的核心构成.