Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monotouch is there a FindName equivalent

Tags:

xamarin.ios

Gradually learning to like mono touch

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

like image 804
PAUL WHITE Avatar asked Dec 17 '25 18:12

PAUL WHITE


2 Answers

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);
like image 189
Philippe Leybaert Avatar answered Dec 20 '25 21:12

Philippe Leybaert


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.

like image 35
miguel.de.icaza Avatar answered Dec 20 '25 21:12

miguel.de.icaza



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!