NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
05/03/14 01:04 PM (10 years ago)

Can not modify UILabels created in XIB (No outlet connection?)

Startiing to add-on to existing XIB files for several plugins, and I am stumped how to hook up my code to these new elements. Background: Started with examining existing XIB code examples(such as 1H4B, CR_pieChart, and bta_thumbviewer) all of these will let me change hidden and color property of existing UILabels via code. (They all have Referencing Outlets shown in XIB) For my new UI elements SETUP seems OK: 1) Add a UILabel to XIB (named *label_Directions 2) .h has required info: IBOutlet UILabel *label_Directions; @property (nonatomic, retain) IBOutlet UILabel *label_Directions; 3) .m has info: @synthesize label_Directions; no errors in xcode. Issue: Neither of these lines of code has any effect for the new elements: self.label_Directions.hidden = YES; self.label_Directions.textColor = [UIColor blackColor]; (Work fine for the existing elements) Several articles point to requirement to expose the new element to the ViewController. Such as: http://codewithchris.com/xcode-tutorial-user-interaction/ However I can not see how to create the Referencing Outlet for the new element??? Not rocket science, I am just trying to toggle visibility and change colors on different screens for starters. Any help would be appreciated. (Hopefully others are at his same stage- not ready to create full new XIB based screens yet, but looking to expand some plugins that already are in place. Pretty sure it is a case of not knowing my way around interface builder in Xcode 5.1 but... Help
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
05/03/14 02:21 PM (10 years ago)
There's a couple ways of doing it. I just created a short video showing how you can add a label and a button to a xib file and make the button do something to the label. It should help you out. http://youtu.be/x6AoNXP8Y44 Hopefully the video quality is good enough to read. It was a large upload, but I think YouTube may have reduced the quality.
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
05/03/14 03:58 PM (10 years ago)
cool nice Chris1 how did you make the background of your code on xcode black? Oh and youtube set the quality low but I could change it to hd by clicking the gear button under the video
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
05/03/14 05:34 PM (10 years ago)
Chris that was a GREAT help. At 55 seconds you had solved my problem. None of the videos and write-ups that I had found on-line had showed *** Dragging from the "New Referencing Outlet" to the "File Owner" *** This is a much see video for Buzz Touch members who have not yet mastered working with XIBs. Thanks again!! PS- CMCOFFEE good tip on changing the resolution :)
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
05/03/14 06:49 PM (10 years ago)
no problem found out how to change background color of screen. Choose Xcode > Preferences and click Fonts & Colors Makes the code easier to read for me. Thanks for asking great questions!
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
05/03/14 07:47 PM (10 years ago)
Nice video, Chris! Thanks, I may try XIBs in the near future.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
05/03/14 07:49 PM (10 years ago)
Yup - quick, easy way to make a screen or a plugin. I'm working on a way to make this even easier. Might be after my move to Oklahoma though.
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
05/04/14 03:06 PM (10 years ago)
People really move from CO to OK ??
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
05/04/14 03:15 PM (10 years ago)
lol
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.