PAUL WHITE
PAUL WHITE

Reputation: 91

Monotouch is there a FindName equivalent

Gradually learning to like mono touch

Is there an equivalent to the FindName function so i can manipulate a control from its "string" name

Upvotes: 3

Views: 58

Answers (2)

miguel.de.icaza
miguel.de.icaza

Reputation: 32694

In addition to the tag as suggested by Philippe, what you can do is create an "Outlet" in your class that references the control, which will give you the equivalent of referencing it by name.

Upvotes: 1

Philippe Leybaert
Philippe Leybaert

Reputation: 171784

UIKit controls (views) don't have names, but they do have tags, which are integer values

You can find a control/subview by calling ViewWithTag():

UIView subview = new UIView(..);
subview.Tag = 100;

parentView.AddSubview(subView);

In another method:

UIView subView = parentView.ViewWithTag(100);

Upvotes: 3

Related Questions