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 –