Accessing labels, textboxes and lauching views from TableViewDatSource
Just new to Monotouch! :D Very glad with it but still in the discovery phase... Hehehe...
I was wondering if i can see/change my labels from within my Table View, for example, in the Main.cs, please take a look:
public partial class AppDelegate : UIApplicationDelegate
{
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
//Do something in here (load my view or any other thing...)
}
public cla开发者_如何学Goss TableViewDataSourceClientes : UITableViewSource
{
//Why can't I access my labels inside this class?
}
}
So, my question is pretty much it. Why i can access my labels and views and textboxes and etc. inside FinishedLauching and not in TableViewDataSourceClientes? ANd how can I achieve this?
My objective is to create a method inside of TableViewDataSourceClientes called RowSelected and change a label text when I select a row.
You cannot access your outlets/labels in the TableViewDataSourceClientes class because they are instance properties on your AppDelegate class. You can get at the AppDelegate from anywhere with UIApplication.SharedApplication.Delegate, you'll need to cast it to your AppDelegate type tho, and then expose the fields / properties you want as public members.
精彩评论