8

Wondering if anyone know hows to complete the following...

In a Storyboard I set my Labels with dummy text, they are not Static text. For example 'User1 Username'.

What I would to know if there is a setting to clear the value of this label when it is loaded by the view. I have some other code that runs off and collects the relevant information. However, it might take a few seconds so a HUD is shown to the user whilst it loads.

Of course in the background of the HUD you can see the example text shown. I know in viewDidLoad I could simply clear all the label texts setting them back to @"", but is there no setting in the storyboard or anything for this?

StuartM
  • 6,743
  • 18
  • 84
  • 160
  • Once you are done with layouting them, you could remove the dummy text? – Marc Apr 16 '14 at 17:25
  • 1
    Not Ideal, using the storyboard is a nice way to view what is expected. I guess as I suggest and per the 'hungry for points' answer below you just have to set them to nil... – StuartM Apr 16 '14 at 20:03
  • If you want to view what you expected and you expect an empty string, then you should in fact set it to empty in the Storyboard. – Marc Apr 17 '14 at 05:37

2 Answers2

19

You can use User Defined Runtime Attributes to achieve this. Simply set "text" attribute for any UILabel, UITextField or UITextView to get what you want:

Using Storyboard runtime attributes to clear label text

KVC and runtime attributes are really powerfull when working with Storyboard (e.g. did you know that you can set "layer.cornerRadius" attribute to any UIView to get rounded corners?).

ncreated
  • 641
  • 1
  • 5
  • 14
-3

Unfortunately, there is no other way to do it. You would have to set the text of the UILabel manually in the ViewDidLoad method:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.myLabel.text = @"";
}
marcopaivaf
  • 199
  • 1
  • 4