커스텀 UITableViewDelegate를 어떻게 구현하고 있습니까? 나는 Monotouch의 UITableViewSource
을 사용하여 UITableViewDataSource
과 UITableViewDelegate
을 하나의 파일에 결합하여 훨씬 쉽게 작업을 수행 할 것을 제안합니다.
일부 예제 코드 :
(당신의 UIViewController
에서 UITableView
포함)이을위한 새로운 클래스를 생성 할 수 있습니다 그리고
tableView.Source = new CustomTableSource();
을 : 그것은해야
public class CustomTableSource : UITableViewSource
{
public CustomTableSource()
{
// constructor
}
// Before you were assigning methods to the delegate/datasource using += but
// in here you'll want to do the following:
public override int RowsInSection (UITableView tableView, int section)
{
// you'll want to return the amount of rows you're expecting
return rowsInt;
}
// you will also need to override the GetCells method as a minimum.
// override any other methods you've used in the Delegate/Datasource
// the one you're looking for in particular is as follows:
public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
// do what you need to here when a row is selected!
}
}
을 시작하는 데 도움이됩니다. UITableViewSource
클래스에서는 항상 public override
을 입력 할 수 있으며 MonoDevelop는 어떤 메소드를 재정의 할 수 있는지 보여줍니다.