【发布时间】:2014-01-30 06:33:28
【问题描述】:
我的 UITableViewController 的每一行都有一个 UIPickerView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CartCell *cell = (CartCell *)[tableView dequeueReusableCellWithIdentifier:@"CartCell"];
Cart *cart = (self.carts)[indexPath.row];
cell.productnameLabel.text = cart.productname;
cell.priceLabel.text = cart.price;
picker = [[UIPickerView alloc]initWithFrame:CGRectMake(70, 0, 100, 40)];
[picker setDelegate:self];
arrayColors = [[NSMutableArray alloc] init];
[arrayColors addObject:@"Red"];
[arrayColors addObject:@"Orange"];
[arrayColors addObject:@"Yellow"];
[arrayColors addObject:@"Green"];
[arrayColors addObject:@"Blue"];
[arrayColors addObject:@"Indigo"];
[arrayColors addObject:@"Violet"];
[cell addSubview:picker];
return cell;
}
我有选择器的 didSelectRow
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
NSLog(@"Selected Color: %@. Index of selected color: %i", [arrayColors objectAtIndex:row], row);
NSIndexPath *path = [self.tableView indexPathForSelectedRow];
NSLog(@"indexPathForSelectedRow %@", path);
}
但我将路径值设为空。 如何在 UITableView 中获取 UIPickerView 值。我需要每一行的选择器值。
【问题讨论】:
-
你想要什么,为什么要创建每个单元格 UIPickerView 和 NSMutableArray ?
-
我在这张表中列出了购物车。我想更新购物车中产品的数量(或颜色)。
标签: objective-c ios7 uitableview uipickerview