TL;DR
I can't seem to populate a UILabel from the viewDidLoad method.
----------------------------------------
Basically, I'm using a root view controller to generate a UITableView / populate it with data from an NSArray (which, in this case uses a plist as a data source).
Each table element links to a new view controller, and at this point in the logic I pull data from the plist (as it's already being accessed to generate the table) and pass it to the view being called.
So I'm passing the data doing this:
exampleController.stringText = [dictionary objectForKey:@"someData"];
In the example controller, I'd like to push the string data into an existing UILabel. However, it only seems to work if I attach it to an IBAction, such as:
And does NOT work if I put those two lines in the viewDidLoad method, which would be ideal (setting the label text on view load without buttonpress or whatever).
What am I missing?
Btw, I'm declaring the NSString *label, UILabel *label in the header, and using properties for 'em, and synthesizing the stringText and label in the implementation file.
This is all very new to me, I'm used to working in Perl/PHP!
*hides in flame suit*
maybe you could put it into method -(void)viewDidAppearBOOL)animated ?
or maybe you are setting that stringText after the viewDidLoad finishes? you should try to put some debugging NSLogs to that method...
but it's also strange, that you are declaring NSString *label and UILabel *label in the same header file? I don't think so... But anyway, why make life more complicated by naming your local variables same as your class variables?
maybe you could put it into method -(void)viewDidAppearBOOL)animated ?
or maybe you are setting that stringText after the viewDidLoad finishes? you should try to put some debugging NSLogs to that method...
but it's also strange, that you are declaring NSString *label and UILabel *label in the same header file? I don't think so... But anyway, why make life more complicated by naming your local variables same as your class variables?
<333
Apparently I don't know the difference between the predefined methods. Thank you! Using viewDidAppear worked!
------------------
Now... if I add multiple labels to a view controller, how do I specify between them in code? I'm sure there's an attribute I set somewhere in Interface Builder, and there's some way to specify which UILabel I'm talking about... but how? o.O
Last edited by masterrex; 09-16-2010 at 09:32 AM.
Reason: Additional question...