gpt4 book ai didi

iphone - UIStepper没有显示

转载 作者:行者123 更新时间:2023-12-01 18:01:54 25 4
gpt4 key购买 nike

我试图以编程方式添加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;
}
if上方的 return cell;语句只是为了在单元格上放置一些标签。

最佳答案

[cell.contentView addSubview:stepper];

编辑:
在您的代码中,您具有:

 [stepper setFrame:CGRectMake(216, 91, 155, 25)];

但是您声称自己的单元格高73像素,宽320像素。

当前,您将步进器设置为155px宽,25px高,x起点为216,y起点为91。

出现在91的y处的步进器在单元的视野之外。

尝试这个:
[stepper setFrame:CGRectMake(216, 22, 100, 30)];

关于iphone - UIStepper没有显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8351180/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com