iphone - 如何用 viewWithTag 隐藏 UILabel?

标签 iphone ios objective-c tags uilabel

我想隐藏 UILabel 但我无法将我的标签隐藏在 ViewDidLoad 之外或“在 ViewDidLoad 之内但在 for 循环之外”。在 for 循环内的 ViewDidLoad 中,我可以实现我想要的。我可以用标签隐藏标签。但是在循环之外它不起作用。

这就是我正在做的。请看一下。

-(void)ViewDidLoad{
int lbl_Pos_X = 580;

for (j=0; j<30; j++) {

    lbl = [[UILabel alloc ] initWithFrame:CGRectMake(lbl_Pos_X, 21, 7, 15)];
    lbl.backgroundColor = [UIColor redColor];
    lbl.tag = j;
    [self.view addSubview:lbl];
    //[lbl release];

    lbl_Pos_X = lbl_Pos_X + 5;


    [lbl viewWithTag:10].hidden = YES;  // here working
    }

     [lbl viewWithTag:12].hidden = YES;  // here  Not working

}

我们非常欢迎任何想法或建议。

最佳答案

尝试使用这个..

UILabel *label = (UILabel *)[self.view viewWithTag:12];
label.hidden = YES;

关于iphone - 如何用 viewWithTag 隐藏 UILabel?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17850186/

相关文章:

iOS Post请求,发送图片Base64编码

ios - AVAudioPlayer 在 Debug模式下抛出断点

iPhone + CSS3 多列 + 溢出 : Scroll = Bug?

iphone - 如何使用 UITextInputMode

ios - 在 Swift 中使用未解析的标识符

ios - 为什么建议对委托(delegate)使用 _weak 引用

iPhone向应用程序添加计时器

iphone - NSURL 连接

android - Qt API 获取应用程序用户数据在 iOS 和 Android 上的保存位置

ios - 消息应用打开通知