如何在UIViewController中使用2 UITableView?

use*_*485 4 objective-c ios4


Plz指导我如何在UIViewController中使用2个UItableView(或更多)并管理它们的
numberOfRowsInSection,......和其他方法.
任何想法?

Alt*_*ice 7

假设您的实际问题在于分配与UITableViewDelegate相同的对象:

UITableViewDelegete方法将UITableView实例传递给它.您只需要过滤掉需要操作的tableview.例如:

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (tableView == yourFirstTableView) {
        // <do whatever on first table view>...
    } else if (tableView == yourSecondTableView) {
        // <do whatever on second table view>...
    }
}
Run Code Online (Sandbox Code Playgroud)