1

I'm creating an IPad application using C#, Mono develop and Monotouch.

I've been using Monotouch.Dialog to create functionality similar to the wifi-settings on an iPhone. I'm using StyledStringElement with an accessory and am now trying to differentiate between tapping the row and tapping the DetailDisclosureButton.

I've been found out that I should override the UITableViewDelegate.AccessoryButtonTapped on the UITableView. I've tried to created a derived class from UITableViewDelegate and hook this into the Monotouch.Dialog. But this is where I got stuck. I didn't manage to replace the existing UITableViewDelegate with my extended version.

So my questions are:

  1. Is this the preferred way of handling this event (to be able to differentiate between a tap on the element and a tap on the DetailDisclosureButton) ?

  2. If not, any pointer on how to accomplish this ?

  3. I have been searching the web for a (similar) example but have not found any yet. Any examples that you know of that could get me started ?

Thanks,

boris

4

1 回答 1

2
event EventHandler accessoryPushed;
public override void AccessoryButtonTapped (UITableView tableView, NSIndexPath indexPath)
{
if(!accessoryPushed)
{
    accessoryPushed(this,EventArgs.Empty);
}


}

您需要将此添加到您正在使用的 DailogViewController 代码中(这将覆盖点击操作)。您可能希望触发一个事件,而不是一个简单的函数,因此只需在主代码中处理该事件即可。这可能是你最好的选择。

更改此行后,您将必须实现诸如 AccessorySelected 之类的新功能(只需模仿选择行时代码遵循的路径,除了附件)。

另一方面,您可以尝试不同的导航方法,通常显示按钮很烦人,您不想单击它们,除非获得有关按钮的简单信息(如帮助功能)。

我还没有找到任何其他的例子,对不起!

于 2011-07-11T18:00:50.523 回答