I went through guide from Apple “Your first iOS app“
and now I have a button, which is not declared in ViewController:
@interface HelloWorldViewController : UIViewController <UITextFieldDelegate>
- (IBAction)changeGreeting:(id)sender;
@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (weak, nonatomic) IBOutlet UILabel *label;
@property (copy, nonatomic) NSString *userName;
@end
Now i can remove label (and textField), using [label removeFromSuperview]; but i dont understand how to do it with button. Can someone help?
You should add an
IBOutletto the button as you did for the textfield and the label:Then you can remove the button using:
Also note that the tutorial you linked to says:
So if you want to remove the button when it is tapped (inside
changeGreeting:), then you don’t need theIBOutletbecause you already have a reference to the button in thesenderparameter: