如何在UI视图上显示两个表 [英] How to display Two tables on a UI view
本文介绍了如何在UI视图上显示两个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在UI视图上使用并显示两个表.请让我知道该怎么做.任何相同的代码也将不胜感激.
I would like to use and display two tables on a UI view. Please let me know how to do this. Any code same will also be appreciated.
谢谢, 桑迪普
推荐答案
- 在IB中的视图中添加2个UITableView,并将它们连接到文件所有者中的2个不同的出口(或简单地分配不同的标记属性).
- 为其设置委托和数据源(可能两者都使用相同的视图控制器).
-
在委托/数据源方法中,您可以执行以下操作:
- Add 2 UITableViews to your view in IB and connect them to 2 different outlets in file owner (or simply assign different tag properties).
- Set delegate and data source for them (may be same view controller for both).
In delegate/data source methods you do the following:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (tableView == myFirstTable)
// return value for 1st table
if (tableView == mySecondTable)
// return value for 2nd table
return 0;
}
或者如果您使用标记方法:
or if you use tag approach:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
switch(tableView.tag){
case firstTag:
// return value for 1st table
case secondTag:
// return value for 2nd table
}
return 0;
}
这篇关于如何在UI视图上显示两个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文