【发布时间】:2011-12-02 02:45:49
【问题描述】:
我试图以编程方式添加 UIStepper,这是我的代码:步进器不会显示。 :
stepper = [[UIStepper alloc]init];
[stepper setFrame:CGRectMake(216, 91, 155, 25)];
[stepper setMinimumValue:0];
[cell addSubview:stepper];
谢谢!
CELLFORROWATINDEXPATH:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
UIStepper * myStepper = [[UIStepper alloc]initWithFrame:CGRectMake(206,20,94,27)];
[myStepper setMinimumValue:0];
[cell addSubview:myStepper];
cellLabel = [[UILabel alloc]init];
[cellLabel setFrame:CGRectMake(65, 22, 27, 27)];
[cellLabel setText:@"1"];
[cell.contentView addSubview:cellLabel];
}
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
cell.imageView.image = [imageArray objectAtIndex:indexPath.row];
// cell.textLabel.text = [cells objectAtIndex:indexPath.row];
if ([cell.imageView.image isEqual:[UIImage imageNamed:@"paddle5.png"]]) {
[cellLabel setFrame:CGRectMake (175, 22, 30, 30)];
}
if ([cell.imageView.image isEqual:[UIImage imageNamed:@"paddle4.png"]]) {
[cellLabel setFrame:CGRectMake (150, 22, 30, 30)];
}
if ([cell.imageView.image isEqual:[UIImage imageNamed:@"paddle3.png"]]) {
[cellLabel setFrame:CGRectMake (120, 22, 30, 30)];
}
if ([cell.imageView.image isEqual:[UIImage imageNamed:@"paddle2.png"]]) {
[cellLabel setFrame:CGRectMake (90, 22, 30, 30)];
}
return cell;
}
return cell; 正上方的 if 语句只是为了在单元格上放置一些标签。
【问题讨论】:
-
告诉我们更多关于细胞的信息。
标签: iphone ios cocoa-touch uitableview