请问 如何在一个view上 显示两个tableview? 我想在一个view上显示两个tableview |
|
![]() |
为何不能?
我给你一个思路。 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 mark – #pragma mark Table view data source // Customize the number of sections in the table view. } // Customize the number of rows in the table view. // Customize the appearance of table view cells. return cell; |
![]() 40分 |
对了,你需要再次打开xib文件,做一下连接,就是两个tableview的datasource,delegate,reference
|
![]() |
谢谢你了 我学会了
但是tableview没有点击事件 我完成后 才发现的。。 只有Navigation View 我要实现的是 左侧的tableview可以点击 并且可以跳转的 |
![]() |
点击事件在另外一个函数,你可以照着上面的例子自己做。
|
![]() |
我也写了2个tableview,但是我的2个tableview的单元格的行数是一样的,这个怎么弄成不一样的,最好谁传个例子来,因为有些人说的方法不行,最好把自己试过可以的方法告诉我
|
![]() |
最好还是自己重写tableview sdk中有好多例子
|
![]() |
干脆写2个viewcontroller应该也可以吧,放在一个统一的controller里面,类似ipad里面的splitviewcontroller
|
![]() |
1楼说的完全可以,我差不多就是这样做的!
|
![]() |
按照1楼说的完全可以,设置左边的TAG值 为0,右边的为1,当发生点击事件时,判断一下这个值,再分发不同的事件,不就行了?1楼的完全可以,只是他是用Xib文件来做的,我当时全是代码写的,相信,1楼的完全可以。
|