I'm trying to create a custom renderer for iOS for use in my .Forms project. The Android one is already working.
This renderer attempts to convert my "WallView" into a UITableView, but I end up with an empty UITableView which bounces back to the top on any attempt to scroll. Any ideas?
[assembly:ExportRenderer(typeof(WallView), typeof(MyNS.iOS.Renderers.WallViewRenderer))]
namespace MyNS.iOS.Renderers
{
public class WallViewRenderer : ViewRenderer<WallView, UITableView> {
protected override void OnElementChanged (ElementChangedEventArgs<WallView> e)
{
base.OnElementChanged (e);
var controller = new WallViewTableViewController (e.NewElement, UITableViewStyle.Plain);
SetNativeControl(controller.TableView);
}
}
. . .
and the matching UITableViewController:
public class WallViewTableViewController : UITableViewController
{
public WallViewTableViewController (WallView view, UITableViewStyle style) : base (style)
{
_view = view;
}
WallView _view;
const string Tag = "WallViewCell";
public override int NumberOfSections (UITableView tableView)
{
return 1;
}
public override int RowsInSection (UITableView tableview, int section)
{
return _view.Items.Count;
}
public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
{
var cell = new UITableViewCell (UITableViewCellStyle.Default, Tag);
cell.ContentView.AddSubview (new UILabel () { Text = "hello world" });
return cell;
}
public override float GetHeightForRow (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
{
return 44;
}
}