Selected UITableView change in Monotouch

I created a custom view hierarchy, somewhere in this hierarchy there is a UITableView, with an output called TableView , so I can contact it from the backend code.

I want to create and push a new view onto the view stack of the root viewcontroller when an item is selected in this list, but I cannot find the relevant events in the UITableView.

All controls were defined using the Interface constructor in the .XIB files.

I'm looking in the wrong place?

early.

+4
source share
2 answers

Yes, you are looking for the wrong place. To use the UITableView events, you must implement the UITableViewSource and assign it as a table. The most common way to do this is in the table view 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! } 

Then you set the MyTableSource class to the Source property of the table view:

 myTableView.Source = new MyTableSource(); 

Note that the UITableViewSource class does not exist in Objective-C. This is just a MonoTouch class that contains both UITableViewDataSource and UITableViewDelegate methods, making things a lot easier.

+11
source

The RowSelected event occurs in a UITableViewSource.

+1
source

Source: https://habr.com/ru/post/1348126/


All Articles