Monotouch Dialog Custom Element和GetHeight未被调用(Monotouch Dialog Custom Element and GetHeight not being called)

使用Monotouch 5.2.11 iOS

我已经按照本教程( http://tirania.org/monomac/archive/2011/Jan-18.html ),创建了一个带有图像的自定义单元格,并且还添加了IElementSizing接口。 永远不会调用GetHeight。

已经提出了类似的问题,普遍接受的解决方案是首先确保并创建RootElements,在将它们添加到Controller之前设置UnEvenRows = true。 这没用。 我已经尝试过以及向根元素添加节的所有其他组合,并且从未见过GetHeight被触发。

MyDataElement是一个320x200的图像,它显示正常,但是后面的字符串元素没有显示(假设它在它后面)。 因此,如果我将自定义单元格拖到顶部上方,它会消失,重新出现,并且第二个元素显示在其上方。

这是我尝试过的代码:

public class MyDataElement : Element, IElementSizing { static NSString key = new NSString ("myDataElement"); public MyData MyData; public MyDataElement (MyData myData) : base (null) { MyData = myData; } public float GetHeight (UITableView tableView, NSIndexPath indexPath){ return 200f; // break point here is never hit ever } public override UITableViewCell GetCell (UITableView tv) { var cell = tv.DequeueReusableCell (key) as MyDataCell; if (cell == null) cell = new MyDataCell (MyData, key); else cell.UpdateCell (MyData); return cell; } public partial class TableTester : DialogViewController { public TableTester () : base (UITableViewStyle.Grouped, null) { var re = new RootElement("Sample") { new Section("Testy") { new MyDataElement(new MyData() { stuff="hello"}), new StringElement("Sample") } }; re.UnevenRows = true; this.Root = re; //this.Root = root; } }

除此之外,我甚至做过这个也不起作用:

public class TestNavigator : UINavigationController { public TestNavigator() { TabBarItem = new UITabBarItem("Test", null, 1); var re = new RootElement("Sample") { new Section("Sammy") { new StringElement("Sample"), new MyDataElement(new MyData() { stuff="sam"}), new StringElement("Sample 2") } }; re.UnevenRows = true; var dv = new DialogViewController(re); re.UnevenRows = true; PushViewController(dv, true); }

Using Monotouch 5.2.11 iOS

I have followed this tutorial (http://tirania.org/monomac/archive/2011/Jan-18.html), created a custom cell with an image and have also added the IElementSizing Interface. The GetHeight is never called.

Similar questions have been asked and the generally accepted solution was to make sure and create the RootElements first, set the UnEvenRows=true before adding them to the Controller. This did not work. I've tried that as well as about every other combination of adding sections to root elements and have not ever seen the GetHeight fired.

The MyDataElement is an image that is 320x200 which displays fine, but the string element that comes after it is not shown (assuming it is behind it). Consequently if I drag the custom cell up above the top, it disappears, reappears, and the second stringelement displays on top of it.

Here is the code I've tried:

public class MyDataElement : Element, IElementSizing { static NSString key = new NSString ("myDataElement"); public MyData MyData; public MyDataElement (MyData myData) : base (null) { MyData = myData; } public float GetHeight (UITableView tableView, NSIndexPath indexPath){ return 200f; // break point here is never hit ever } public override UITableViewCell GetCell (UITableView tv) { var cell = tv.DequeueReusableCell (key) as MyDataCell; if (cell == null) cell = new MyDataCell (MyData, key); else cell.UpdateCell (MyData); return cell; } public partial class TableTester : DialogViewController { public TableTester () : base (UITableViewStyle.Grouped, null) { var re = new RootElement("Sample") { new Section("Testy") { new MyDataElement(new MyData() { stuff="hello"}), new StringElement("Sample") } }; re.UnevenRows = true; this.Root = re; //this.Root = root; } }

In addition to that I've even done this which didn't work either:

public class TestNavigator : UINavigationController { public TestNavigator() { TabBarItem = new UITabBarItem("Test", null, 1); var re = new RootElement("Sample") { new Section("Sammy") { new StringElement("Sample"), new MyDataElement(new MyData() { stuff="sam"}), new StringElement("Sample 2") } }; re.UnevenRows = true; var dv = new DialogViewController(re); re.UnevenRows = true; PushViewController(dv, true); }

最满意答案

经过大量的试验和错误,我必须确保并删除我从github下载的Monotouch.Dialog的引用并使用内置引用。 似乎gheub可能会破坏getheight。

After plenty of trial and error, I had to make sure and remove the reference to Monotouch.Dialog that I had downloaded from github and use the built in reference. It seems that the getheight maybe broken in github.

Monotouch Dialog Custom Element和GetHeight未被调用(Monotouch Dialog Custom Element and GetHeight not being called)

使用Monotouch 5.2.11 iOS

我已经按照本教程( http://tirania.org/monomac/archive/2011/Jan-18.html ),创建了一个带有图像的自定义单元格,并且还添加了IElementSizing接口。 永远不会调用GetHeight。

已经提出了类似的问题,普遍接受的解决方案是首先确保并创建RootElements,在将它们添加到Controller之前设置UnEvenRows = true。 这没用。 我已经尝试过以及向根元素添加节的所有其他组合,并且从未见过GetHeight被触发。

MyDataElement是一个320x200的图像,它显示正常,但是后面的字符串元素没有显示(假设它在它后面)。 因此,如果我将自定义单元格拖到顶部上方,它会消失,重新出现,并且第二个元素显示在其上方。

这是我尝试过的代码:

public class MyDataElement : Element, IElementSizing { static NSString key = new NSString ("myDataElement"); public MyData MyData; public MyDataElement (MyData myData) : base (null) { MyData = myData; } public float GetHeight (UITableView tableView, NSIndexPath indexPath){ return 200f; // break point here is never hit ever } public override UITableViewCell GetCell (UITableView tv) { var cell = tv.DequeueReusableCell (key) as MyDataCell; if (cell == null) cell = new MyDataCell (MyData, key); else cell.UpdateCell (MyData); return cell; } public partial class TableTester : DialogViewController { public TableTester () : base (UITableViewStyle.Grouped, null) { var re = new RootElement("Sample") { new Section("Testy") { new MyDataElement(new MyData() { stuff="hello"}), new StringElement("Sample") } }; re.UnevenRows = true; this.Root = re; //this.Root = root; } }

除此之外,我甚至做过这个也不起作用:

public class TestNavigator : UINavigationController { public TestNavigator() { TabBarItem = new UITabBarItem("Test", null, 1); var re = new RootElement("Sample") { new Section("Sammy") { new StringElement("Sample"), new MyDataElement(new MyData() { stuff="sam"}), new StringElement("Sample 2") } }; re.UnevenRows = true; var dv = new DialogViewController(re); re.UnevenRows = true; PushViewController(dv, true); }

Using Monotouch 5.2.11 iOS

I have followed this tutorial (http://tirania.org/monomac/archive/2011/Jan-18.html), created a custom cell with an image and have also added the IElementSizing Interface. The GetHeight is never called.

Similar questions have been asked and the generally accepted solution was to make sure and create the RootElements first, set the UnEvenRows=true before adding them to the Controller. This did not work. I've tried that as well as about every other combination of adding sections to root elements and have not ever seen the GetHeight fired.

The MyDataElement is an image that is 320x200 which displays fine, but the string element that comes after it is not shown (assuming it is behind it). Consequently if I drag the custom cell up above the top, it disappears, reappears, and the second stringelement displays on top of it.

Here is the code I've tried:

public class MyDataElement : Element, IElementSizing { static NSString key = new NSString ("myDataElement"); public MyData MyData; public MyDataElement (MyData myData) : base (null) { MyData = myData; } public float GetHeight (UITableView tableView, NSIndexPath indexPath){ return 200f; // break point here is never hit ever } public override UITableViewCell GetCell (UITableView tv) { var cell = tv.DequeueReusableCell (key) as MyDataCell; if (cell == null) cell = new MyDataCell (MyData, key); else cell.UpdateCell (MyData); return cell; } public partial class TableTester : DialogViewController { public TableTester () : base (UITableViewStyle.Grouped, null) { var re = new RootElement("Sample") { new Section("Testy") { new MyDataElement(new MyData() { stuff="hello"}), new StringElement("Sample") } }; re.UnevenRows = true; this.Root = re; //this.Root = root; } }

In addition to that I've even done this which didn't work either:

public class TestNavigator : UINavigationController { public TestNavigator() { TabBarItem = new UITabBarItem("Test", null, 1); var re = new RootElement("Sample") { new Section("Sammy") { new StringElement("Sample"), new MyDataElement(new MyData() { stuff="sam"}), new StringElement("Sample 2") } }; re.UnevenRows = true; var dv = new DialogViewController(re); re.UnevenRows = true; PushViewController(dv, true); }

最满意答案

经过大量的试验和错误,我必须确保并删除我从github下载的Monotouch.Dialog的引用并使用内置引用。 似乎gheub可能会破坏getheight。

After plenty of trial and error, I had to make sure and remove the reference to Monotouch.Dialog that I had downloaded from github and use the built in reference. It seems that the getheight maybe broken in github.