I created a custom hierarchy of views, somewhere in this hierarchy is a UITableView, with an outlet called TableView
, so i can reach it from backend code.
I want to create and push a new view to the root viewcontroller's view stack when an item in that list is selected, but i can not find any relevant events on the UITableView.
All controls were defined using Interface builder in .XIB files
Am i looking in the wrong place?
thanks in advance.
Yes, you are looking in the wrong place. To use UITableView's "events", you have to implement a UITableViewSource
and assign it to your table view. The most common way to do it is in the table view's controller as a nested class:
private class MyTableSource : UITableViewSource
{
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
{
// Do something for the selected row
}
// Override both RowsInSection and GetCell methods!
}
You then set the MyTableSource class to the table view's Source property:
myTableView.Source = new MyTableSource();
Note that the UITableViewSource class does not exist in Objective-C. It is merely a MonoTouch class that hosts both UITableViewDataSource's and UITableViewDelegate's methods, making things a lot simpler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With