我有三個tableView一個包含類cateogry一個containg類型和其他產品名稱我想當用戶選擇任何類別的類型數組應在運行時加載獲取相同類型的選擇的類別如何在運行時加載數組中的項目
在我的例子,如果我選擇類別的除草劑,那麼它應該在插入的arrayType中
typeHerbicides的內容,但是當我加載表第二它不顯示任何值
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
//自定義nu在表視圖中的行數。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (tableView ==tblSimpleTable)
return [categoryArray count];
else if(tableView==tblSimpleTableType)
return [typeArray count];
else if(tableView==tblSimpleTableProduct)
return [productArray count];
else if(tableView==tblSimpleTableOneSection)
return [categorySectionOneArray count];
else if(tableView==tblSimpleTableTypeSection)
return [typeArraySection count];
else
return [productArraySection count];
}
//自定義表格視圖單元格的外觀。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
if (tableView ==tblSimpleTable) {
cell.textLabel.font=[UIFont fontWithName:@"Arial" size:16];
cell.textLabel.text = [categoryArray objectAtIndex:indexPath.row];
return cell;
}
else if (tableView==tblSimpleTableType){
cell.textLabel.font=[UIFont fontWithName:@"Arial" size:16];
cell.textLabel.text = [typeArray objectAtIndex:indexPath.row];
return cell;
}
else if(tableView==tblSimpleTableProduct) {
cell.textLabel.font=[UIFont fontWithName:@"Arial" size:16];
cell.textLabel.text = [productArray objectAtIndex:indexPath.row];
return cell;
}
else if(tableView==tblSimpleTableOneSection){
cell.textLabel.font=[UIFont fontWithName:@"Arial" size:16];
cell.textLabel.text = [categorySectionOneArray objectAtIndex:indexPath.row];
return cell;
}
else if(tableView==tblSimpleTableTypeSection){
cell.textLabel.font=[UIFont fontWithName:@"Arial" size:16];
cell.textLabel.text = [typeArraySection objectAtIndex:indexPath.row];
return cell;
}
else {
cell.textLabel.font=[UIFont fontWithName:@"Arial" size:16];
cell.textLabel.text = [productArraySection objectAtIndex:indexPath.row];
return cell;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView ==tblSimpleTable) {
titleCategory=[categoryArray objectAtIndex:indexPath.row];
NSLog(@"This is titleCategory Selected %@",titleCategory);
NSString*[email protected]"Herbicides";
if([titleCategory isEqualToString:test]){
typeHerbicides=[[NSArray alloc] initWithObjects:@"ACCLAIM EXTRA",@"ILLOXAN",@"REVOLVER",nil];
typeArray=[[NSArray alloc] initWithArray:typeHerbicides copyItems:YES];
}
else {
typeArray=[[NSArray alloc] initWithObjects:@"ILLOXAN",@"REVOLVER",nil];
typeArray=[[NSArray alloc] initWithArray:typeHerbicides copyItems:YES];
}
}
else if(tableView==tblSimpleTableType)
titleType=[typeArray objectAtIndex:indexPath.row];
else if(tableView==tblSimpleTableProduct)
titleProduct=[productArray objectAtIndex:indexPath.row];
else if(tableView==tblSimpleTableOneSection)
titleSectionOneCategory=[categorySectionOneArray objectAtIndex:indexPath.row];
else if(tableView==tblSimpleTableTypeSection)
titleTypeSection=[typeArraySection objectAtIndex:indexPath.row];
else
titleProductSection=[productArraySection objectAtIndex:indexPath.row];
}