在我的应用程序中,我想在一个 ViewController
中使用 3 个表格 View .问题是如何使用 UITableViewDelegate
方法分开。例如;我可以使用 cellForRowAtIndexPath
为每个 UITableView
单独使用方法通过标记。但是,我不知道如何使用 numberOfRowsInSection
或 numberOfSectionsInTableView
每个 TableView 的方法不同。是否可以?
最佳答案
制作 3 UITableView
中的变量YourViewController.h :
YourViewController : UIViewController
{
UITableView* tableView1;
UITableView* tableView2;
UITableView* tableView3;
}
YourViewController.m:
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView == tableView1)
{
//Your code
}
if (tableView == tableView2)
{
//Your code
}
if (tableView == tableView3)
{
//Your code
}
}
关于iphone - 在 View Controller 中使用多个 TableView 时使用委托(delegate)方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14978455/