0
我有兩個單元格一個部分和另一個行。如何創建下拉表格視圖使用兩個自定義單元格?
這是我的代碼
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return arrname.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(collapse==section)
{
return [arrDescription count]+1;
}
else
{
return 1;
}
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// productCell =[[productScreenCell alloc]init];
productCell=[tableView dequeueReusableCellWithIdentifier:@"cell"];
productSub=[tableView dequeueReusableCellWithIdentifier:@"cell1"];
if(indexPath.row==0)
{
if(arrname.count>0)
{
NSString *str=[NSString stringWithFormat:[email protected]"%@",[arrimages objectAtIndex:indexPath.row]];
productCell.lblCostProduct.text=[NSString stringWithFormat:@"%@",[arrcost objectAtIndex:indexPath.section]];
productCell.imgProduct.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:str]]];
productCell.backgroundColor=[UIColor colorFromHexString:@"#232323"];
productCell.lblProductScreen.text=[NSString stringWithFormat:@"%@",[arrname objectAtIndex:indexPath.section]];
[productCell.btnClick addTarget:self action:@selector(touchup:) forControlEvents:UIControlEventTouchUpInside];
productCell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
}
}
else
{
productSub.lblSubProduct.text=[NSString stringWithFormat:@"%@",[arrDescription objectAtIndex:indexPath.row-1]];
}
//
productCell.btnClick.backgroundColor=[UIColor colorFromHexString:@"#ffc400"];
productCell.btnClick.tag=indexPath.row;
return productCell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ if (indexPath.row == 0 && collapse != indexPath.section) {
collapse = (int)indexPath.section;
[tableView reloadData];
}
else
{
}
}
我已經搜查了許多下拉代碼片段,但一切都還不清楚,或者它應該是第三方程序,任何不要只給我簡單的下拉表列表編碼爲了我。
如果可能的話請發送代碼@luke Smith –