我有兩個表在同一個類,我需要每個表包含不同的數據,但我有麻煩的委託...如何使每個表包含一個單獨的委託?謝謝,我的英語很抱歉。 。兩個UITableView在同一個類中?數據源和委託
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1; }
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [dataTable1 count];
}
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
CeldaFamilia *cell = (CeldaFamilia *)[aTableView dequeueReusableCellWithIdentifier:@"CeldaFamilia"];
if (!cell) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CeldaFamilia" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.propTextFamilia.text =[dataTable1 objectAtIndex:indexPath.row];
return cell;
}
爲什麼這些方法有參數'tableView'有一個特殊的原因。主要原因是你可以做'如果[tableView isEqual:tv1] ...'。 –