Thanks Mikkel. But I forgot to say that I'm using Interface Builder so, also knowing now that is possible to use custom controls from IB, the code don't will populate the id for each control.. So that's why maybe the best try could be get the outlet name connected to each label
Is that possible? Karl From: Mikkel Lønow <[email protected]> Date: Fri, 16 Sep 2011 10:42:19 +0200 To: Karl Heinz Brehme Arredondo <[email protected]> Cc: "[email protected]" <[email protected]> Subject: Re: [MonoTouch] Find ID of a control Hello, You could extend your control and put the field in it you need. Try this: public class MyLabel : UILabel { public int Id { get; set; } } And in your loop you do: foreach (var control in this.View.Subviews) { if (control is MyLabel) control.Text = NSBundle.MainBundle.LocalizedString(control.Id, ""); } Hope this helps. Mikkel On Fri, Sep 16, 2011 at 07:07, Karl Heinz Brehme Arredondo <[email protected]> wrote: > Hi, > > Is there a way to get the ID (aka name of the variable or Outlet name) of a > control? > > I need to loop for all controls and then do something like that: > > foreach (UIView view in this.View.Subviews) > { > If (view.GetType().Name == "UILabel") > { > view.Text = NSBundle.MainBundle.LocalizedString(view.ID, ""); > } > } > > So all controls that has a corresponding Localizable.srings file with it ID as > key for localization can be translated automatically depending on > Localizable.srings. > > Thanks, > > Karl > > _______________________________________________ > MonoTouch mailing list > [email protected] > http://lists.ximian.com/mailman/listinfo/monotouch >
_______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
