我正在将一个本机Objective-C应用程序移植到Monotouch解决方案中.
我的故事板中有一个tableview,带有一些静态表格单元格.
使用以下目标-c代码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;
}
Run Code Online (Sandbox Code Playgroud)
现在我想在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)
{
// …Run Code Online (Sandbox Code Playgroud)