andyong Posted April 27, 2010 Share Posted April 27, 2010 Hi all, Does anyone know how to connect actions and outlets programmatically? Basically I have a few text fields that are hidden when the view loads, and depending on some user input I want to be able to create some new objects in the viewcontroller or appdelegate and once created call some methods to link those objects via outlets to be able to update those UITextFields, and conversely link actions methods from the UIControl objects to prompt modifications to the created objects. Any help would be appreciated. Thanks, Andy Link to comment Share on other sites More sharing options...
andyong Posted April 28, 2010 Author Share Posted April 28, 2010 Seems like you can wire up actions using something like. Still looking for outlet mapping. [btn addTarget:self action:@selector(buttonClickActionMethod) forControlEvents:UIControlEventTouchUpInside]; Link to comment Share on other sites More sharing options...
andyong Posted May 7, 2010 Author Share Posted May 7, 2010 So here's a little update. The previous post works fine to programmatically link/wire up actions to events on controls like UITextfields, UIButtons, etc. The reason you would be doing this I'd expect is because you are creating these textfields, buttons, etc. programmatically too like myself. In regards to connecting outlets you don't need to worry about this. Once you've created the object for the UITextfield, for example, you can modify properties for it (in particular its .text property) in your code and it is automatically reflected on the drawn object. You don't need to make modifications to the objects then initiate redraw functions as all of that is handled for you. Link to comment Share on other sites More sharing options...
Recommended Posts