在做这个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. fiddler修改请求和返回

    一.修改请求 1.先设置请求前断点 2.设置拦截,在左下角的QuickExec命令行中输入bpu www.baidu.com/XXXX 3.选中需要修改的请求,选中Inspectors面板,使用Raw ...

  2. ES6遍历器 生成器 学习整理

    遍历器[迭代器](Iterator) 就是这样一种机制.它是一种接口,为各种不同的数据结构提供统一的访问机制.任何数据结构只要部署 Iterator 接口,就可以完成遍历操作(即依次处理该数据结构的所 ...

  3. 通用分页jsp页面显示

    注:本章内容都是在上一篇文章 通用分页后台显示:https://www.cnblogs.com/ly-0919/p/11058942.html  的基础上进行改进,所以有许多的类都在上一篇, 带来不便 ...

  4. myeclipse不同版本共存破解办法

    我自己破解的是myeclipse10+myeclipse2018: 方法是:先破解myeclipse10.7,使用破解工具,到最后一步不关闭破解工具,再进行替换文件那一步,路径不选择10版本的,换成M ...

  5. jQuery获取元素的方式

    一.通过id选择器获取并操作元素--------$("#id属性的值") <script src="http://libs.baidu.com/jquery/1.1 ...

  6. 「CF150E」Freezing with Style「点分治」「单调队列」

    题意 给定一颗带边权的树,求一条边数在\(L\).\(R\)之间的路径,并使得路径上边权的中位数最大.输出一条可行路径的两个端点.这里若有偶数个数,中位数为中间靠右的那个. \(n, L, R\leq ...

  7. java.lang.OutOfMemoryError:PermGen space tomcat7 内存溢出

    Tomcat 解决 在启动项目的时候,会报java.lang.OutOfMemoryError:PermGen space错误. 在tomcat/bin/catalina.sh  windows li ...

  8. Kalman实际应用总结

    目录 Kalman理论介绍 一. 简单理论介绍理论 二. 升华理论介绍 Kalman基本应用 一. Kalman跟踪/滤波 二. Kalman预测/融合(单传感器) 三. Kalman多传感器融合A ...

  9. manjaro xfce4 使用super+D快捷键显示桌面(以及使用super+方向键调整窗口)设置无效

    xfce4 有两个地方设置快捷键:Keyboard -> application shortcuts 和 window manager -> keyboard. window manage ...

  10. 1 课务 iOS 概述

    重要注意 紫色解释 蓝色分类 新内容 CS193P 本课老版本 2010 年冬 http://open.163.com/movie/2010/6/C/7/M6RU83DCT_M6RU957C7.htm ...