Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Allow customisation of each cell in a Section before its used #180

Closed
wants to merge 1 commit into from

2 participants

@nicwise

this came out of my Evolve talk.

Allows a Section to customise its elements before they are used - so you can change the background of the element correctly without changing how the element works.

Another way could be to make the Section implement an interface like IElementResizing, not sure if an otherwise blank method call is quicker/better than a "if (x is ISectionCustomisation)" type call. Happy to rework if it is.

Should have submitted this a year ago. :(

@nicwise nicwise Added to DVC and Section to allow each cell in a section to be custom…
…ized before it's used. Allows for consistent changes to a section, eg changing the background image
1489738
@migueldeicaza

Is this related to one of the questions that folks asked at Evolve?

@nicwise
@migueldeicaza

So this kind of customization should be done by a subclass of the source, there is no need to add this directly to the source code.

You are going from having to customize the internal data source, to having to customize a Section subclass. Small gain, but one that impacts every cell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 21, 2013
  1. @nicwise

    Added to DVC and Section to allow each cell in a section to be custom…

    nicwise authored
    …ized before it's used. Allows for consistent changes to a section, eg changing the background image
This page is out of date. Refresh to see the latest.
View
2  MonoTouch.Dialog/DialogViewController.cs
@@ -338,7 +338,7 @@ public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Founda
var section = Root.Sections [indexPath.Section];
var element = section.Elements [indexPath.Row];
- return element.GetCell (tableView);
+ return section.CustomizeCell(element.GetCell (tableView), indexPath);
}
public override void WillDisplay (UITableView tableView, UITableViewCell cell, NSIndexPath indexPath)
View
6 MonoTouch.Dialog/Elements.cs
@@ -2343,6 +2343,12 @@ public override UITableViewCell GetCell (UITableView tv)
return cell;
}
+
+ public virtual UITableViewCell CustomizeCell(UITableViewCell source, NSIndexPath indexPath)
+ {
+ return source;
+ }
+
}
/// <summary>
Something went wrong with that request. Please try again.