3

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

tgebarowski
  • 1,189
  • 11
  • 14
Jesuslg123
  • 726
  • 6
  • 16
  • Thanks, but I will need to do that for each element, and when data is back from server put back to 1, more complex than use "User defined runtime attributes" – Jesuslg123 Sep 29 '15 at 10:23

3 Answers3

1

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.

JAY RAPARKA
  • 1,353
  • 2
  • 13
  • 33
  • About the first option, I would like to void need to write a line for each view that I want to clean, for that the "User defined runtime attributes" is cleaner/simple, I looking for something more "clean", maybe using the interface builder, like the constraint option "Remove at build time". About the second, as I said, I want to keep text on xib/viewcontroller to make easy when working on the view, otherwise I will have a view with "transparent" elements. – Jesuslg123 Sep 29 '15 at 09:29
1

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];
                }
            }
        }
    }
}
Zoltán
  • 1,422
  • 17
  • 22
0

duplicate of Clear Label text used in Storyboard

set the "text" property to en empty string in the user defined runtime attributes.

stephane k.
  • 1,668
  • 20
  • 21