I would like to know if there are any way to remove a button text or label text on compile time.
I have a view which download the content data from server, so meanwhile the request is happening I would like to have empty texts, and I would like to keep the text I am using on xcode, just on Xcode, in order to make easy find views and have more descriptive views on my Xcode while developing.
Right now for each view that I want to do that, I'm using "User defined runtime attributes", to set to the text value to empty string, but I would like to know if there is a better way to do that.
Thanks
set text empty on viewWillAppear method
[btnDontHaveAnAccountYet setTitle:@"" forState:UIControlStateNormal]
and when you get response than reset the button title.
problem solve no need to set runtime text.
OR ELSE
just keep blank button text when you put it in xib/Viewcontroller.
you can use what ever you like both are easy and both are working.
How about this?
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self removeLabelsFrom:self.view];
}
- (void) removeLabelsFrom:(UIView *)view {
for (UIView *subView in view.subviews) {
if ([subView isKindOfClass:[UIButton class]]) {
UIButton *button;
button = (UIButton *)subView;
[button setTitle:@"" forState:UIControlStateNormal];
} else {
if ([subView isKindOfClass:[UILabel class]]) {
UILabel *label;
label = (UILabel *)subView;
label.text = @"";
} else {
if (subView.subviews.count > 0) {
[self removeLabelsFrom:subView];
}
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With