Quote:
Originally Posted by Jolly1
Hello All, very new to this.
I am using IB. I have done the separate controllers, they're working fine, and I'm intercepting actions from some test buttons I have set up in each of the controllers.
However, I can't seem to figure out how to connect my outlets? In other words, I need to be able to change the text in a label in a particular view, and I can't seem to figure out how to attach that label to any of my classes within IB.
I assume I have to subclass UIView? How does that work with my separate .xib files? I'm a bit confused around the edges here.
Thanks, this thread is great!
Jolly
|
Jolly. I try to give an example using the viewOne as our subject:
in the ViewOne.XIB set the File's Owner class as ViewOneController (via the last tab in the inspector - Class identity section).
Create IBOutlets(in .h file, along with @property, and in .M file use @synthesize) in the ViewOneController for each IB field,label etc that you need to change/read. In IB you can now connect the label to the File's Owner and select the IBOutlet corresponding to the item you select.
f.i:
//.h file
IBOutlet UILabel *mylabel;
} //end of class definition
@property (nonatomic, retain)IBOutlet UILabel *mylabel;
//.M file
@synthesize myLabel;
//it now has setMyLabel and getMyLabel since its a property.
From code, you can now access the field/label/.. using self.myLabel.text or [self setMyLabel].
i wrote this up in 1 min so try if its syntax correct but i hope you get the idea..