我以编程方式创建了一个UILabel
并触发了一个我想隐藏相同标签的按钮。这是我的代码:
UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 320, 100)];
nameLabel.text = @"TEXT";
nameLabel.backgroundColor = [UIColor greenColor];
nameLabel.numberOfLines = 5;
nameLabel.font = [UIFont boldSystemFontOfSize:12];
[self.view addSubview:nameLabel];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"Hide" style:UIBarButtonItemStyleBordered target:self action:@selector(back)];
- (IBAction)back{
self.navigationItem.rightBarButtonItem=nil;
[nameLabel setHidden: YES]; not working
nameLabel.hidden = YES; not working
}
我错过了什么吗?