Two UITableView in the same view

前端 未结 6 775
Happy的楠姐
Happy的楠姐 2020-12-05 15:16

I want to know if it\'s allowed to use Multiple UItableView in the same View (i don\'t see any thing in the Apple\'s Human Interface Guidelines) and if it\'s OK

6条回答
  •  独厮守ぢ
    2020-12-05 15:43

    Yes you can. The issue is that each UITableView will use the same UITableViewDataSource and UITableViewDelegate. Therefore you must determine which table view you are working with in each of the necessary delegate methods.

    For example:

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
        // make bigger rows
    
        if (tableView == myBigRowTableView)
        {
            // make bigger rows
            return 127;
        } else if (tableView == mySmallRowTableView) {
            // make smaller rows
            return 20;
        } else {
            return 30;
        } 
    }
    

提交回复
热议问题