我想在 UI 视图上使用和显示两个表。请让我知道如何执行此操作。任何相同的代码也将受到赞赏。
谢谢,
桑迪普
- 将 2 个 UITableView 添加到 IB 中的视图中,并将它们连接到文件所有者中的 2 个不同的出口(或者简单地分配不同的标签属性)。
- 为它们设置委托和数据源(两者可能是相同的视图控制器)。
-
在委托/数据源方法中,您执行以下操作:
-(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;
}
或者如果您使用标签方法:
- (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;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)