¿Es posible usar un getter/setter para el texto de una UILabel en MonoTouch?
Frecuentes
Visto 233 veces
1
Tengo el siguiente código
public string QuestionText
{
get { return txtBox.Text; }
set {txtBox.Text = value; }
}
where txtBox is a UILabel and everytime I try to access it via QuestionText I get a Null Reference Exception. Am I able to set and get the text like this?
1 Respuestas
1
este producto está hecho por encargo con un tiempo de producción de XNUMX a XNUMX semanas txtBox
será nulo hasta ViewDidLoad
ocurre.
A better solution if you are running into that issue:
public string QuestionText { get; set; }
public override void ViewDidLoad()
{
base.ViewDidLoad();
txtBox.Text = QuestionText;
}
Respondido 29 ago 12, 13:08
Es posible que también necesite usar ViewWillAppear
instead, if your controller can be viewed more than once. - jonathanpeppers
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas c# iphone ios mono xamarin.ios or haz tu propia pregunta.
Yes if your txtBox is initialized. - Renatas M.
@Reniuz I thought it did this within my designer class? - Smoore
Check that it does exist in your designer class - sometimes MonoDevelop doesn't integrate well with Xcode & IBOutlets don't show up. - SomaMan