iOS 两个tableview 实现 瀑布流
来源:互联网 发布:网络监控软件排行 编辑:程序博客网 时间:2024/05/21 12:08
001
//
002
// DocViewController.m
003
// getrightbutton
004
//
005
// Created by 隋文涛 on 12-12-9.
006
// Copyright (c) 2012年 隋文涛. All rights reserved.
007
//
008
009
#import"DocViewController.h"
010
#defineheightofimage(image)image.size.height*150.0/image.size.width
011
012
@interfaceDocViewController ()
013
{
014
NSMutableArray*arrdata;
015
NSMutableArray*arrdata1;
016
NSMutableArray*arrdata2;
017
NSMutableArray*arrdata1_1;
018
NSMutableArray*arrdata2_1;
019
float
he1,he2;
020
}
021
022
@property (weak, nonatomic)IBOutlet UITableView *tableview01;
023
@property (weak, nonatomic)IBOutlet UITableView *tableview02;
024
025
@end
026
027
@implementationDocViewController
028
@synthesizetableview01,tableview02;
029
030
- (
void
)viewDidLoad
031
{
032
[superviewDidLoad];
033
//Do any additional setup after loading the view, typically from anib.
034
[[NSNotificationCenterdefaultCenter] addObserver:self selector:@selector(Backhome)name:@
"Back"
object:nil];
035
036
he1= 0.0;
037
he2= 0.0;
038
arrdata1= [[NSMutableArray alloc] initWithCapacity:1];
039
arrdata2= [[NSMutableArray alloc] initWithCapacity:1];
040
arrdata1_1= [[NSMutableArray alloc] initWithCapacity:1];
041
arrdata2_1= [[NSMutableArray alloc] initWithCapacity:1];
042
for
(
int
i = 1; i < 11; i++) {
043
UIImage*image = [UIImage imageNamed:[NSStringstringWithFormat:@
"%d.jpeg"
,i]];
044
float
hecu =image.size.height*150.0/image.size.width;
045
046
if
(he2 >= he1) {
047
he1= he1 + hecu;
048
NSArray*arr = [[NSArray alloc] initWithObjects:[NSStringstringWithFormat:@
"%d"
,i],[NSStringstringWithFormat:@
"%f"
,hecu], nil];
049
// [arrdata1_1 addObject:[NSStringstringWithFormat:@"%d",i]];
050
// [arrdata1_1 addObject:[NSStringstringWithFormat:@"%f",hecu]];
051
[arrdata1addObject:arr];
052
}
else
{
053
he2= he2 + hecu;
054
NSArray*arr = [[NSArray alloc] initWithObjects:[NSStringstringWithFormat:@
"%d"
,i],[NSStringstringWithFormat:@
"%f"
,hecu], nil];
055
[arrdata2addObject:arr];
056
}
057
NSLog(@
"%f(h1= %f,,,,h2 = %f)"
,hecu,he1,he2);
058
}
059
tableview01.showsVerticalScrollIndicator= NO;
060
tableview02.showsVerticalScrollIndicator= NO;
061
NSLog(@
"%@+++++++%@"
,arrdata1,arrdata2);
062
}
063
064
-(NSInteger)tableView:(UITableView *)tableViewnumberOfRowsInSection:(NSInteger)section{
065
// return 100;
066
if
(tableView == tableview01) {
067
return
[arrdata1 count];
068
}
else
{
069
return
[arrdata2 count];
070
}
071
return
0;
072
}
073
074
- (UITableViewCell*)tableView:(UITableView *)tableViewcellForRowAtIndexPath:(NSIndexPath *)indexPath{
075
NSIntegerrow = indexPath.row;
076
077
078
if
(tableView == tableview01) {
079
// tableview02
080
// [tableview02setContentOffset:tableview01.contentOffset];
081
static
NSString *id1 = @
"sd1"
;
082
UITableViewCell*cell = [tableViewdequeueReusableCellWithIdentifier:id1];
083
if
(cell == nil) {
084
NSArray*nib = [[NSBundle mainBundle] loadNibNamed:@
"CellView"
owner:selfoptions:nil];
085
if
(nib > 0) {
086
cell= _ccell;
087
}
088
}
089
UIImage*image = [UIImage imageNamed:[NSStringstringWithFormat:@
"%d.jpeg"
,[[[arrdata1objectAtIndex:row] objectAtIndex:0] integerValue]]];
090
UIImageView*imageview = (UIImageView *)[cell viewWithTag:101];
091
[imageviewsetImage:image];
092
CGRectrect = imageview.frame;
093
rect.size.height= [[[arrdata1 objectAtIndex:row] objectAtIndex:1]floatValue];
094
imageview.frame= rect;
095
return
cell;
096
097
}
else
{
098
// [tableview01setContentOffset:tableview02.contentOffset];
099
static
NSString *id = @
"sd"
;
100
UITableViewCell*cell = [tableViewdequeueReusableCellWithIdentifier:id];
101
if
(cell == nil) {
102
NSArray*nib = [[NSBundle mainBundle] loadNibNamed:@
"CellView"
owner:selfoptions:nil];
103
if
(nib > 0) {
104
cell= _ccell;
105
}
106
}
107
UIImage*image = [UIImage imageNamed:[NSStringstringWithFormat:@
"%d.jpeg"
,[[[arrdata2objectAtIndex:row] objectAtIndex:0] integerValue]]];
108
UIImageView*imageview = (UIImageView *)[cell viewWithTag:101];
109
[imageviewsetImage:image];
110
CGRectrect = imageview.frame;
111
rect.size.height= [[[arrdata2 objectAtIndex:row] objectAtIndex:1]floatValue];
112
imageview.frame= rect;
113
return
cell;
114
115
}
116
return
nil;
117
}
118
119
- (
float
)tableView:(UITableView *)tableViewheightForRowAtIndexPath:(NSIndexPath *)indexPath{
120
NSIntegerrow = indexPath.row;
121
if
(tableView == tableview01) {
122
return
[[[arrdata1 objectAtIndex:row] objectAtIndex:1]floatValue] +10;
123
}
else
{
124
return
[[[arrdata2 objectAtIndex:row] objectAtIndex:1]floatValue] +10;
125
}
126
return
0.0;
127
}
128
129
- (
void
)tableView:(UITableView *)tableViewdidSelectRowAtIndexPath:(NSIndexPath *)indexPath{
130
DocwebViewController*controller = [[DocwebViewController alloc] init];
131
[selfpresentModalViewController:controller animated:YES];
132
}
133
134
- (
void
)Backhome{
135
[selfdismissModalViewControllerAnimated:YES];
136
}
137
138
- (
void
)scrollViewDidScroll:(UIScrollView*)scrollView{
139
if
(scrollView == tableview01) {
140
[tableview02setContentOffset:tableview01.contentOffset];
141
}
else
{
142
[tableview01setContentOffset:tableview02.contentOffset];
143
}
144
145
}
146
147
- (
void
)didReceiveMemoryWarning
148
{
149
[superdidReceiveMemoryWarning];
150
//Dispose of any resources that can be recreated.
151
}
152
153
@end
0 0
- iOS 两个tableview 实现 瀑布流
- iOS 使用两个tableview的瀑布流
- iOS 两个tableview的 瀑布流
- TableView 瀑布流实现
- ios实现两个tableview联动
- ios实现两个tableview联动
- iOS 瀑布流实现
- iOS 实现瀑布流界面
- iOS 实现 瀑布流界面
- iOS瀑布流的实现
- IOS瀑布流实现原理
- iOS collectionView实现瀑布流
- iOS 瀑布流基本实现
- iOS 瀑布流基本实现
- iOS两个 TableView 联动
- 在iOS上实现瀑布流界面
- 在iOS上实现瀑布流界面
- IOS如何实现灵活的瀑布流
- 消灭星星源代码(c语言实现)
- 克鲁斯卡尔(Kruskal)算法求最小生成树
- 可视化的数据结构 - 各种算法动画演示
- mysql 事务简介
- TCP连接的建立(二)
- iOS 两个tableview 实现 瀑布流
- UVALive - 3644 X-Plosives
- 联合变量的赋值和使用
- Spring事务管理
- C语言可变参数在宏定义中的应用
- iOS利用CoreLocation获取地理位置以及如何在模拟器进行调试
- 【j2ee】数据库中取出数据到list中,结果list中数据一样
- linux中class_create和class_register分析
- 最后的 PDP