Skip to content

Instantly share code, notes, and snippets.

@spouliot
Created November 19, 2011 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spouliot/1379500 to your computer and use it in GitHub Desktop.
Save spouliot/1379500 to your computer and use it in GitHub Desktop.
patch to add AccessoryTapped in MonoTouch.Dialog
diff --git a/MonoTouch.Dialog/DialogViewController.cs b/MonoTouch.Dialog/DialogViewController.cs
index 19bbf70..f7828d8 100644
--- a/MonoTouch.Dialog/DialogViewController.cs
+++ b/MonoTouch.Dialog/DialogViewController.cs
@@ -300,6 +300,14 @@ namespace MonoTouch.Dialog
Root = container.root;
}
+ public override void AccessoryButtonTapped (UITableView tableView, NSIndexPath indexPath)
+ {
+ var section = Root.Sections [indexPath.Section];
+ var element = (section.Elements [indexPath.Row] as StyledStringElement);
+ if (element != null)
+ element.AccessoryTap ();
+ }
+
public override int RowsInSection (UITableView tableview, int section)
{
var s = Root.Sections [section];
diff --git a/MonoTouch.Dialog/Elements.cs b/MonoTouch.Dialog/Elements.cs
index 7e79295..c931a3d 100644
--- a/MonoTouch.Dialog/Elements.cs
+++ b/MonoTouch.Dialog/Elements.cs
@@ -699,6 +699,7 @@ namespace MonoTouch.Dialog
}
protected UITableViewCellStyle style;
+ public NSAction AccessoryTapped;
public UIFont Font;
public UIFont SubtitleFont;
public UIColor TextColor;
@@ -867,6 +868,13 @@ namespace MonoTouch.Dialog
return;
root.TableView.ReloadRows (new NSIndexPath [] { IndexPath }, UITableViewRowAnimation.None);
}
+
+ internal void AccessoryTap ()
+ {
+ NSAction tapped = AccessoryTapped;
+ if (tapped != null)
+ tapped ();
+ }
}
public class StyledMultilineElement : StyledStringElement, IElementSizing {
@seanmcleod
Copy link

Why is there an assumption that only StyledStringElement elements have an AccessoryTap() method?

I've implemented a UIViewElement derived element which sets the details accessory but since it isn't a StyledStringElement the patch above doesn't propagate AccessoryTap to my element.

Regards

@spouliot
Copy link
Author

Honestly I don't recall. Likely it was the only place where the accessory button was exposed. I suggest you to propose a more general fix (as a push request) directly to Miguel's git repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment