iphone - 在 View Controller 中使用多个 TableView 时使用委托(delegate)方法

标签 iphone ios objective-c uitableview

在我的应用程序中,我想在一个 ViewController 中使用 3 个表格 View .问题是如何使用 UITableViewDelegate方法分开。例如;我可以使用 cellForRowAtIndexPath为每个 UITableView 单独使用方法通过标记。但是,我不知道如何使用 numberOfRowsInSectionnumberOfSectionsInTableView每个 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/

相关文章:

ios - 在不延迟当前操作的情况下触发 NSNotification

iphone - 如何保存来自不同 View Controller 的数据并将其加载到 iOS 中的另一个 View Controller 中

ios - SKAction 暂停播放声音循环

iphone - 如何在应用程序中使用 iPhone 铃声

iphone - 是否存在将在 Objective-C 中转换日语搜索字符串的现有代码

objective-c - 如何在iOS中以编程方式添加UITabBarItem的标识符类型?

iphone - 无法将 sqlite 数据库从应用程序的主包复制到用户文档

ios - iOS MDM 操作中的证书内容

objective-c - SKPaymentTransaction expires_date,似乎 "auto renew"机制在沙箱中不起作用

ios - QuickDialog QEntryElement 省略号和重叠问题