2010-12-31 4 views

Répondre

7

En supposant que votre problème réel réside dans l'attribution du même objet que UITableViewDelegate:

UITableViewDelegete méthodes passent l'instance UITableView à elle. Vous avez juste besoin de filtrer quelle vue de table vous devez opérer. Par exemple:

- (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>... 
    } 
} 
+0

+1. On dirait que nous tapions en même temps. – taskinoor

+0

Ouais, devinez. – Altealice

0
if(tableView1){ 
    if(section==0) 
     return 1; /* 1 row for section 0 in the first table. */ 
    if(section==1) 
     return 2; /* 2 rows for section 1 in the first table. */ 
} 

if(tableView2){ 
    if(section==0) 
     return 3; /* 3 row for section 0 in the second table. */ 
    if(section==1) 
     return 2; /* 2 rows for section 1 in the second table. */ 
} 
+0

votre si la condition sera toujours réussie! – Selvin

0

pourquoi allez-vous utiliser deux tableviews dans UIViewController? .Il est possible, jeu d'étiquettes à chacun des tableview vous êtes adding.u pouvez vérifier ces balises dans les méthodes de délégués et faire des changements.

3
 
// tableView parameter is the tableView for which the delegate method is called 
// u can compare this with your table view references 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    if (tableView == myTableView1) { 
     // return data for myTableView1 
    } else if (tableView == myTableView2) { 
     // return data for myTableView2 
    } 
} 
0

tag utilisation .. pour View1 table par exemple l'utilisation en tant que tag = 0 et utiliser la table view2 comme étiquette

Questions connexes