When trying to center an image in a custom ImageElement in MonoTouch.Dialog, I'm having some issues. I've tried just about every technique in the book, from setting the image's center to the cell's center, adjusting content modes, etc.
My current approach:
public class MoveButtonElement : ImageElement, IElementSizing
{
UIActionSheet ActionSheet;
UIActionSheetDelegate ActionSheetDelegate;
static NSString key = new NSString ("ButtonElement");
public MoveButtonElement () : base (null) { }
protected override NSString CellKey
{
get
{
return key;
}
}
public float GetHeight (UITableView tableView, NSIndexPath indexPath)
{
return 53;
}
public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
{
// SetupAndShowActionSheet (dvc);
}
public override UITableViewCell GetCell (UITableView tv)
{
var cell = base.GetCell (tv);
cell.BackgroundView = null;
cell.BackgroundColor = UIColor.Clear;
cell.ContentMode = UIViewContentMode.Center;
cell.SelectionStyle = UITableViewCellSelectionStyle.None;
cell.ImageView.Image = Images.MoveVerseButton;
cell.ImageView.ContentMode = UIViewContentMode.Redraw;
return cell;
}
}