【问题标题】:UILabel backgroundcolor is not updating in some of the iPhone and iPod device某些 iPhone 和 iPod 设备中的 UILabel 背景颜色未更新
【发布时间】:2010-02-26 12:50:21
【问题描述】:

我正在 iphone 应用程序中为我的自定义日历动态创建 30 个 UIButton。我还将 UILabel 添加为每个 UIButton 中的子视图。我正在为每个 UILabel 设置不同的背景颜色。

当我尝试更改 UILabel 的背景颜色时,在某些 iPhone 设备上它工作正常,但在某些 iPod touch 和 iPhone 设备上不显示任何颜色。它的行为就像我设置了 clearColor。

这是我加载一个单元格的基本代码。我将这个逻辑保持在循环中,我正在使用 UIButton 数组来创建多个单元格:

calenderCell = [UIButton buttonWithType:UIButtonTypeCustom];
calenderCell.frame = CGRectMake(xOffset, yOffset, cellWidth, cellHeight);
calenderCell.backgroundColor = [UIColor clearColor];
[calenderCell addTarget:self action:@selector(calenderCellClicked:)  
                          forControlEvents:UIControlEventTouchUpInside];

calenderCellDate=[[UILabel alloc] initWithFrame:CGRectMake(1.0,1.0, cellWidth-1.0, cellHeight-1.0)];
calenderCellDate.text = [NSString stringWithFormat:@"%ld",dateValue];
calenderCellDate.textAlignment = UITextAlignmentCenter;
calenderCellDate.font = [UIFont fontWithName:@"Trebuchet MS" size:15.0];
calenderCellDate.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1.0];
calenderCellDate.textColor = [UIColor colorWithRed:0.44 green:0.44 blue:0.44 alpha:1.0];
[calenderCell addSubview:calenderCellDate];
[calenderCellDate release];

谁能知道这段代码有什么问题?

感谢您的帮助。

谢谢,
吉姆。

【问题讨论】:

    标签: iphone uilabel


    【解决方案1】:

    我想通了。存在与区域和语言环境设置相关的问题。对于美国来说,它运行良好,但对于中国、德国、意大利等其他地区,由于日期比较,上述代码未执行。

    该代码一切正常。

    谢谢,
    吉姆。

    【讨论】:

      猜你喜欢
      • 2011-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-14
      • 2023-03-03
      • 2010-09-18
      • 1970-01-01
      • 2012-07-09
      相关资源
      最近更新 更多