Marko
Marko

Reputation: 72222

iPhone - Accessing dynamic controls after creation

I'm creating a number of UITextFields dynamically based on fields in the database (inside ViewDidLoad) and would like to know how I can refer to the text fields later?

Normally in Interface Builder I would set an Outlet and then refer to the outlet when I need it, do I need to do the same programmatically?

If not, can I add them to a collection and then loop through them instead?

I'm using MonoTouch, but interested to know how you'd do this the Obj-C way as well.

Many Thanks,

M

Upvotes: 1

Views: 396

Answers (2)

KingofBliss
KingofBliss

Reputation: 15115

Set the tag value, then access it using

UITextField *tf=(UITextField *)[self.view viewWithTag:tagValue];

Upvotes: 3

shannoga
shannoga

Reputation: 19869

You can tag them and store them in array and then loop by the tag.

Upvotes: 0

Related Questions