iOS 两个tableview的 瀑布流
iOS 两个tableview的 瀑布流
1. [代码]Objective-C
//
// DocViewController.m
// getrightbutton
//
// Created by 隋文涛 on 12-12-9.
// Copyright (c) 2012年 隋文涛. All rights reserved.
//
#import "DocViewController.h"
#define heightofimage(image) image.size.height*150.0/image.size.width
@interface DocViewController ()
{
NSMutableArray *arrdata;
NSMutableArray *arrdata1;
NSMutableArray *arrdata2;
NSMutableArray *arrdata1_1;
NSMutableArray *arrdata2_1;
float he1,he2;
}
@property (weak, nonatomic) IBOutlet UITableView *tableview01;
@property (weak, nonatomic) IBOutlet UITableView *tableview02;
@end
@implementation DocViewController
@synthesize tableview01,tableview02;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(Backhome) name:@"Back" object:nil];
he1 = 0.0;
he2 = 0.0;
arrdata1 = [[NSMutableArray alloc] initWithCapacity:1];
arrdata2 = [[NSMutableArray alloc] initWithCapacity:1];
arrdata1_1 = [[NSMutableArray alloc] initWithCapacity:1];
arrdata2_1 = [[NSMutableArray alloc] initWithCapacity:1];
for (int i = 1; i < 11; i++) {
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpeg",i]];
float hecu = image.size.height*150.0/image.size.width;
if (he2 >= he1) {
he1 = he1 + hecu;
NSArray *arr = [[NSArray alloc] initWithObjects:[NSString stringWithFormat:@"%d",i],[NSString stringWithFormat:@"%f",hecu], nil];
// [arrdata1_1 addObject:[NSString stringWithFormat:@"%d",i]];
// [arrdata1_1 addObject:[NSString stringWithFormat:@"%f",hecu]];
[arrdata1 addObject:arr];
}else{
he2 = he2 + hecu;
NSArray *arr = [[NSArray alloc] initWithObjects:[NSString stringWithFormat:@"%d",i],[NSString stringWithFormat:@"%f",hecu], nil];
[arrdata2 addObject:arr];
}
NSLog(@"%f(h1 = %f,,,,h2 = %f)",hecu,he1,he2);
}
tableview01.showsVerticalScrollIndicator = NO;
tableview02.showsVerticalScrollIndicator = NO;
NSLog(@"%@+++++++%@",arrdata1,arrdata2);
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
// return 100;
if (tableView == tableview01) {
return [arrdata1 count];
}else{
return [arrdata2 count];
}
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSInteger row = indexPath.row;
if (tableView == tableview01) {
// tableview02
// [tableview02 setContentOffset:tableview01.contentOffset];
static NSString *id1 = @"sd1";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:id1];
if (cell == nil) {http://www.huiyi8.com/vi/
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CellView" owner:self options:nil];
if (nib > 0) {
cell = _ccell;
}
}
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpeg",[[[arrdata1 objectAtIndex:row] objectAtIndex:0] integerValue]]];
UIImageView *imageview = (UIImageView *)[cell viewWithTag:101];
[imageview setImage:image];vi模版大全
CGRect rect = imageview.frame;
rect.size.height = [[[arrdata1 objectAtIndex:row] objectAtIndex:1] floatValue];
imageview.frame = rect;
return cell;
}else{
// [tableview01 setContentOffset:tableview02.contentOffset];
static NSString *id = @"sd";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:id];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CellView" owner:self options:nil];
if (nib > 0) {
cell = _ccell;
}
}
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpeg",[[[arrdata2 objectAtIndex:row] objectAtIndex:0] integerValue]]];
UIImageView *imageview = (UIImageView *)[cell viewWithTag:101];
[imageview setImage:image];
CGRect rect = imageview.frame;
rect.size.height = [[[arrdata2 objectAtIndex:row] objectAtIndex:1] floatValue];
imageview.frame = rect;
return cell;
}
return nil;
}
- (float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
NSInteger row = indexPath.row;
if (tableView == tableview01) {
return [[[arrdata1 objectAtIndex:row] objectAtIndex:1] floatValue] +10;
}else{
return [[[arrdata2 objectAtIndex:row] objectAtIndex:1] floatValue] +10;
}
return 0.0;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
DocwebViewController *controller = [[DocwebViewController alloc] init];
[self presentModalViewController:controller animated:YES];
}
- (void)Backhome{
[self dismissModalViewControllerAnimated:YES];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
if (scrollView == tableview01) {
[tableview02 setContentOffset:tableview01.contentOffset];
}else{
[tableview01 setContentOffset:tableview02.contentOffset];
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
效果图:
iOS 两个tableview的 瀑布流的更多相关文章
- iOS 使用两个tableview的瀑布流
代码 悦德财富:https://www.yuedecaifu.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ...
- iOS教你轻松打造瀑布流Layout
前言 : 在写这篇文章之前, 先祝贺自己, 属于我的GitHub终于来了. 这也是我的GitHub的第一份代码, 以下文章的代码均可以在Demo clone或下载. 欢迎大家给予意见. 觉得写得不错的 ...
- iOS GZWaterfall任何形式的瀑布流
概述 使用UICollectionView可以布局各种各样的瀑布流,下面我写了几种不同布局的瀑布流样式 详细 代码下载:http://www.demodashi.com/demo/11018.html ...
- ios 两个 TableView 之间的联动, TableView 与 CollectionView 之间的联动
两个 TableView 之间的联动, TableView 与 CollectionView 之间的联动 这是一个创建于 359 天前的主题,其中的信息可能已经有所发展或是发生改变. [联动] :两个 ...
- iOS瀑布流实现(Swift)
这段时间突然想到一个很久之前用到的知识-瀑布流,本来想用一个简单的方法,发现自己走入了歧途,最终只能狠下心来重写UICollectionViewFlowLayout.下面我将用两种方法实现瀑布流,以及 ...
- IOS 瀑布流
本篇博客应该算的上CollectionView的高级应用了,从iOS开发之窥探UICollectionViewController(一)到今天的(五),可谓是由浅入深的窥探了一下UICollectio ...
- IOS 瀑布流UICollectionView实现
IOS 瀑布流UICollectionView实现 在实现瀑布流之前先来看看瀑布流的雏形(此方法的雏形 UICollectionView) 对于UICollectionView我们有几点注意事项 它和 ...
- iOS横向瀑布流的封装
前段时间, 做一个羡慕, 需要使用到瀑布流! 说道瀑布流, 或许大家都不陌生, 瀑布流的实现也有很多种! 从scrollView 到 tableView 书写的瀑布流, 然后再到2012年iOS6 苹 ...
- iOS 瀑布流之栅格布局
代码地址如下:http://www.demodashi.com/demo/14760.html 一 .效果预览 二.确定需求 由下面的需求示意图可知模块的最小单位是正方形,边长是屏幕宽除去边距间隔后的 ...
随机推荐
- Ext grid单元格编辑时获取获取Ext.grid.column.Column
item2.width = 80; //item2.flex = 1; item2.align = 'center'; item2.menuDisabled = true; //禁止显示列头部右侧菜单 ...
- 使用Crashlytics来保存应用崩溃信息
使用Crashlytics来保存应用崩溃信息 本文首发于InfoQ,版权归InfoQ所有,转载请保留原文链接. 简介 Crashlytic 成立于2011年,是专门为移动应用开者发提供的保存和分析应用 ...
- 【spring boot】在Spring mvc中controller中可以拿到对象信息,但是返回给前台却是什么也没有,解决方案
如图所示: 最后: 问题解决: 这个原因是因为,User类并未给字段提供get/set方法,所以给前台传递过去的值是空的. 解决方案: 为User类添lombok的注解@Data,为实体类提供get/ ...
- GridView数据绑定控件的模版列时设置显示的格式
形式 语法 结果 数字 {0:N2} 12.36 数字 {0:N0} 13 货币 {0:c2} $12.36 货币 {0:c4} $12.3656 货币 "¥{0:N2}&q ...
- Qt跨平台的一个例程
我的同事penk在近期北京的Hackathon展示了一个在多平台的例程. 非常多开发人员对这个挺感兴趣的. 今天我就把这个资源介绍给大家. 这是同一个用Qt写的应用.能够同一时候在Ubuntu Des ...
- Cocos2d-x初识
cocos2d-x引擎是什么 在学习游戏的时候就有意的搜索这方面的知识,知道游戏须要游戏引擎,引擎听着非常厉害,只是就是一个游戏框架. 或许某一个游戏框架火起来了,就非常流行了,只是我觉得不论什么游戏 ...
- javascript 转义函数
// 字符转义 html2Escape(sHtml) { return sHtml.replace(/[<>&"]/g, function(c) { return { ' ...
- odoo高级物流应用:跨厂区生产
业务情景 半成品在分厂生产,然后再在总厂组装 半成品所需的原材料存储在分厂的仓库 总厂需要的原材料储存在总厂的仓库 公用的原材料储存在总厂的仓库 解决方案 使用仓库间的供应 设置合适的Rout ...
- 计算机的一些经典书籍CS经典书单
c++: <c++程序设计> <c++primer> <effective c++> <more effective c++> <深入探索c++对 ...
- SpringBoot学习之pom文件常见错误
错误1 上图的错误需要添加jar包的版本号,springboot自动生成不需要添加版本号,手动添加的需要指定版本号. 所以pom.xml如下方式: