【问题标题】:Change the text in a subview dynamically动态更改子视图中的文本
【发布时间】:2012-01-24 09:58:00
【问题描述】:

我通过创建继承自 UIView 的新类为 MyView 创建了 3 个子视图。 然后我尝试更改特定子视图中的文本,例如第二个子视图。 但它没有更新。那么如何做到这一点......

编辑

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{
   CALayer *hitLater = [self layerForTouch:[touches anyObject]]; 
   if ([hitLater isKindOfClass:[Tile class]]) 
   {
      Tile *tile = (Tile *)hitLater; 
      heldTile = tile; 
      [tile draw2]; 
      [tile setNeedsDisplay]; 
   } 
}

提前谢谢..

【问题讨论】:

  • 如果您展示一些代码说明您是如何做到这一点的,我们可以为您提供更好的帮助!

标签: iphone view subview


【解决方案1】:

如果您想要更好的答案,请显示一些代码以及如何将文本添加到 UIView 子类等。 但也许你必须在你的子视图上调用 setNeedsDisplay 才能重绘它们。

【讨论】:

  • - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { CALayer *hitLater = [self layerForTouch:[touches anyObject]]; if ([hitLater isKindOfClass:[Tile class]]) { Tile *tile = (Tile *)hitLater;持有瓷砖=瓷砖; [平铺画2]; [平铺设置需要显示]; } }
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多