简体   繁体   中英

Single Array Value to show multiple tableview on one viewController

I am developing Iphone Application.Using Three table view on Single viewcontroller. value show on those tableview's on single array but problem is that those array value show on first tableview not on other two tableview's. please help Thanks in advance

code..

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [_arrayResult count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"cell";
    UITableViewCell *cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil){
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    MEObject *obj = [_arrayResult objectAtIndex:indexPath.row];
    if (tableView == _tableView) {
        cell.textLabel.text= obj.emp_client_name;
    }
    if (tableView == _secondTableView) {
        cell.textLabel.text= obj.emp_event_name;
    }
    if (tableView == _thirdTableView) {
        cell.textLabel.text=obj.emp_client_name;
    }
    return cell;
}

Please cross check if you are setting datasource and delegates of all 3 tables to viewcontroller.

When you set your _arrayResult, you need to reload all 3 table view

_arrayResult = @[a,b,c];
[table1 reloadData];
[table2 reloadData];
[table3 reloadData];

After once you set the datasource/Delegate to the all three tableview. I haven't seen any datasource allocation as per your tableview. Like if tableview == tableview1 {

Return first array

}

Can you please try giving name to those tableview on outlet and then for each datasource and delegates function call as per your requirement but before check which tableview is displayed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM