Я переношу собственное приложение цели -C в решение Monotouch.
В моей раскадровке есть табличное представление с некоторыми статическими ячейками таблицы.
Используя следующую цель -c code a получил выбор из таблицы
- (void) tableView:(UITableView *) aTableView didSelectRowAtIndexPath:(NSIndexPath *) indexPath
{ // remove the row highlight
[aTableView deselectRowAtIndexPath:indexPath animated:YES];
switch(indexPath.row) {
case 0: [self callWebsite]; break;
case 1: [self sendEmail]; break;
case 2: [self makePhoneCall]; break;
}
return;
}
Теперь я хочу сделать то же самое в MonoTouch, но не могу понять как, и все примеры, которые я нашел в сети, используют DataSource и UITableViewDelegate.
Но при таком подходе Мои "Статические" ячейки удаляются, заменяются.
Вот что я пытаюсь сделать.
public partial class ContactViewController : UITableViewController
{
public ContactViewController (IntPtr handle) : base (handle)
{
this.TableView.Delegate = new CustomTableViewDelegate();
}
}
public class CustomTableViewDelegate : UITableViewDelegate
{
public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
// Remove the row highlight
RowDeselected(tableView, indexPath);
/*
// Is this section our "button" section?
switch(indexPath.row) {
case 0: [self callWebsite]; break;
case 1: [self sendEmail]; break;
case 2: [self makePhoneCall]; break;
}
*/
Console.WriteLine("Do something meaningfull.");
}
}
У кого-нибудь есть предложения?