代码

悦德财富: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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//
//  DocViewController.m
//  getrightbutton
//
//
 
#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) {
            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];
        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的瀑布流的更多相关文章

  1. iOS 两个tableview的 瀑布流

    iOS 两个tableview的 瀑布流1. [代码]Objective-C     ////  DocViewController.m//  getrightbutton////  Created ...

  2. ios 让两个tableView同时处于选中状态

    - (void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath { [_l ...

  3. iOS瀑布流实现(Swift)

    这段时间突然想到一个很久之前用到的知识-瀑布流,本来想用一个简单的方法,发现自己走入了歧途,最终只能狠下心来重写UICollectionViewFlowLayout.下面我将用两种方法实现瀑布流,以及 ...

  4. IOS 瀑布流

    本篇博客应该算的上CollectionView的高级应用了,从iOS开发之窥探UICollectionViewController(一)到今天的(五),可谓是由浅入深的窥探了一下UICollectio ...

  5. IOS 瀑布流UICollectionView实现

    IOS 瀑布流UICollectionView实现 在实现瀑布流之前先来看看瀑布流的雏形(此方法的雏形 UICollectionView) 对于UICollectionView我们有几点注意事项 它和 ...

  6. iOS横向瀑布流的封装

    前段时间, 做一个羡慕, 需要使用到瀑布流! 说道瀑布流, 或许大家都不陌生, 瀑布流的实现也有很多种! 从scrollView 到 tableView 书写的瀑布流, 然后再到2012年iOS6 苹 ...

  7. iOS 瀑布流之栅格布局

    代码地址如下:http://www.demodashi.com/demo/14760.html 一 .效果预览 二.确定需求 由下面的需求示意图可知模块的最小单位是正方形,边长是屏幕宽除去边距间隔后的 ...

  8. iOS开发:一个瀑布流的设计与实现(已实现缓存池功能,该功能使得瀑布流cell可以循环利用)

    一个瀑布流的实现有三种方式: 继承自UIScrollView,仿写UITableView的dataSource和delegate,创造一个缓存池用来实现循环利用cell 写多个UITableview( ...

  9. iOS开发:代码通用性以及其规范 第一篇(附带,自定义UITextView\进度条\双表显示\瀑布流 代码设计思路)

    在iOS团队开发中,我见过一些人的代码,也修改过他们的代码.有的人的代码写的非常之规范.通用,几乎不用交流,就可以知道如何修改以及在它基础上扩展延生.有的人的代码写的很垃圾,一眼看过去,简直会怀疑自己 ...

随机推荐

  1. unicode 和 utf-8 的关系和解释

    首先一个字节就是8个晶体管同时发出的信号集, unicode就是一套编码,所有的字符都用2个字节表示,不像gbk和gb2312既保持了以前的ansi/ascii的字符单个字节编码,有发明了两个字节保存 ...

  2. Unity3d多线程

    http://blog.csdn.net/dingkun520wy/article/details/49181645 (一)多线程的创建 Thread t = new Thread(new Threa ...

  3. Java replace() 方法

    Java replace() 方法 Java String类 replace() 方法通过用 newChar 字符替换字符串中出现的所有 oldChar 字符,并返回替换后的新字符串. 语法 publ ...

  4. 扩展Date的DateDiff方法--日期差

    Date.prototype.DateDiff = function(after){ var diffDay; var beforeDate = new Date(this).format(" ...

  5. Js作用域链及变量作用域

    要理解变量的作用域范围就得先理解作用域链 用var关键字声明一个变量时,就是为该变量所在的对象添加了一个属性. 作用域链:由于js的变量都是对象的属性,而该对象可能又是其它对象的属性,而所有的对象都是 ...

  6. Android系统启动过程-uBoot+Kernel+Android

    摘要:本文是参考大量网上资源在结合自己查看源代码总结出来的,让自己同时也让大家加深对Android系统启动过程有一个更加深入的了解!再次强调,本文的大多数功劳应归功于那些原创者们,同时一些必要的参考链 ...

  7. 《javascript高级程序设计》 第20章 JSON

    20.1 语法 20.1.1 简单值 20.1.2 对象 20.1.3 数组 20.2 解析与序列化 20.2.1 JSON 对象 20.2.2 序列化选项 20.2.3 解析选项 JSON 对象有两 ...

  8. WPF:linq

    /// <summary> /// 该药品是否存在发药信息 /// 存在返回true,否则返回false /// </summary> /// <param name=& ...

  9. hdu----(4308)Saving Princess claire_(搜索)

    Saving Princess claire_ Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/ ...

  10. ios基础篇(五)——UITextField的详细使用

    UItextFieldField通常用于外部数据输入,以实现人机交互. 以下是UItextFieldField的属性及常见用法: 1.textField :设置文本框的默认文本. 2.Placehol ...