请问 如何在一个view上 显示两个tableview? 请问 如何在一个view上 显示两个tableview?我想在一个view上显示两个tableview一个在左边 一个在右边 怎么做到呢? 在线等 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 为何不能?我给你一个思路。1.创建一个View-based Application,比如test2.在打开testViewController.xib3.在view上放上两个tableview,一个在左,一个在右,只需要拖动鼠标来改变大小和位置。当然你可以使用代码来创建两个uitableview,然后加到view上,用代码指定位置和大小。其实我想你的问题是如何在一个viewcontroller中为两个tableview指定数据源和代理。下面就是答案。4.在testViewController.h中修改代码如下:@interface testViewController : UIViewController<UITableViewDelegate, UITableViewDataSource> {@public int testiv; UITableView *tab1; UITableView *tab2;}@property(nonatomic, retain)IBOutlet UITableView *tab1;@property(nonatomic, retain)IBOutlet UITableView *tab2;5.在testViewController.m中改一下代码#pragma -#pragma Table view data source// Customize the number of sections in the table view.- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { if(tableView == tab1) return 1; else { return 2; }}// Customize the number of rows in the table view.- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if(tableView == tab1) return 1; else { return 2; }}// Customize the appearance of table view cells.- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; if(tableView == tab1) cell.textLabel.text = @"111"; else { cell.textLabel.text = @"222"; } } // Configure the cell. return cell;} 对了,你需要再次打开xib文件,做一下连接,就是两个tableview的datasource,delegate,reference 谢谢你了 我学会了 但是tableview没有点击事件我完成后 才发现的。。 只有Navigation View我要实现的是 左侧的tableview可以点击 并且可以跳转的 我也写了2个tableview,但是我的2个tableview的单元格的行数是一样的,这个怎么弄成不一样的,最好谁传个例子来,因为有些人说的方法不行,最好把自己试过可以的方法告诉我 最好还是自己重写tableview sdk中有好多例子 干脆写2个viewcontroller应该也可以吧,放在一个统一的controller里面,类似ipad里面的splitviewcontroller 按照1楼说的完全可以,设置左边的TAG值 为0,右边的为1,当发生点击事件时,判断一下这个值,再分发不同的事件,不就行了?1楼的完全可以,只是他是用Xib文件来做的,我当时全是代码写的,相信,1楼的完全可以。 用CLLocationManager得到当前城市和国家的名称。 从webservice读取xml到本地 乔布斯 去世了。悼念。。。。 ios设备推送icon上显示数量的问题 跪求大神帮助,X宝买的IPAD3还原后遇到ID锁无法激活了 [福利]swift中文版手册(完整版) 请问如何编码控制Label中文字的位置 发布证书不能通过organizer导入设备的吗? titleBar用tableview还是scrollview做比较好? ios百度地图开发指南针不显示的问题 在两个view之间切换的问题 xcode3.2.6 和4.2能否共存?
我给你一个思路。
1.创建一个View-based Application,比如test
2.在打开testViewController.xib
3.在view上放上两个tableview,一个在左,一个在右,只需要拖动鼠标来改变大小和位置。
当然你可以使用代码来创建两个uitableview,然后加到view上,用代码指定位置和大小。
其实我想你的问题是如何在一个viewcontroller中为两个tableview指定数据源和代理。
下面就是答案。
4.在testViewController.h中修改代码如下:
@interface testViewController : UIViewController<UITableViewDelegate, UITableViewDataSource> {
@public
int testiv;
UITableView *tab1;
UITableView *tab2;
}
@property(nonatomic, retain)IBOutlet UITableView *tab1;
@property(nonatomic, retain)IBOutlet UITableView *tab2;
5.在testViewController.m中改一下代码
#pragma -
#pragma Table view data source// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
if(tableView == tab1)
return 1;
else {
return 2;
}}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if(tableView == tab1)
return 1;
else {
return 2;
}
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
if(tableView == tab1)
cell.textLabel.text = @"111";
else {
cell.textLabel.text = @"222";
}
}
// Configure the cell.
return cell;
}
但是tableview没有点击事件
我完成后 才发现的。。 只有Navigation View
我要实现的是 左侧的tableview可以点击 并且可以跳转的