我在for循環中手動添加了按鈕,之後,如何隱藏或更改按鈕並隱藏標籤?在Cocoa Touch中手動添加按鈕後如何隱藏按鈕?
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(80.0, 170, 150.0, 30.0);
[button setTitle:@"My Button" forState:UIControlStateNormal];
[button addTarget:self action:@selector(myAction:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
UILabel *lblFileName = [[UILabel alloc] init];
lblFileName.text = [[objectArray objectAtIndex:i] valueForKey:@"fileName"];
lblFileName.textAlignment = NSTextAlignmentCenter;
[self.view addSubview:lblFileName];
-(IBAction)myAction:(id)sender
{
// hide the button or change title button and hide label
}
您想隱藏與特定按鈕相關的所有標籤或標籤。 – Girish
與特定按鈕相關的標籤 –
請試用我更新的答案。 – Girish