如何从放置在TableHeader中的按钮回调到UiViewController(在Xamarin.iOS中)

问题描述:

我将按钮放置在TableHeader的单击中,我想发送回调到我的UIViewController。如何从放置在TableHeader中的按钮回调到UiViewController(在Xamarin.iOS中)

任何人都可以请建议如何实现它主要使用C#或其他斯威夫特。我在C#中

有什么特别的tableHeader?

public Action<object, EventArgs> VCAction; 

btn.TouchUpInside += (s, e) => 
     { 
      //VCAction.Invoke(s, e); 
     }; 

btn.TouchUpInside += Btn_TouchUpInside; 

void Btn_TouchUpInside(object sender, EventArgs e) 
    { 
     //VCAction.Invoke(s, e); 
    } 

UIButtontarget:应设置为UIViewController & selector:作为负责处理点击手势功能编写代码。

在你delegate method tableView(_:viewForHeaderInSection:) where you return your header细胞,补充一点:

[button addTarget:self action:@selector(yourActionMethod:) forControlEvents:UIControlEventTouchUpInside]; 

Swift 3 Method

button.addTarget(self, action:#selector(handleRegister()), for: .touchUpInside).