Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin.ios 未调用Monotouch对话框自定义元素和GetHeight_Xamarin.ios_Monotouch.dialog - Fatal编程技术网

Xamarin.ios 未调用Monotouch对话框自定义元素和GetHeight

Xamarin.ios 未调用Monotouch对话框自定义元素和GetHeight,xamarin.ios,monotouch.dialog,Xamarin.ios,Monotouch.dialog,使用Monotouch 5.2.11 iOS 我遵循本教程,创建了一个带有图像的自定义单元格,并添加了IElementSizing界面。从未调用GetHeight 已经提出了类似的问题,普遍接受的解决方案是首先确保并创建根元素,在将它们添加到控制器之前设置rows=true。这不起作用。我尝试过这种方法,也尝试过将节添加到根元素的其他组合,但从未见过启动GetHeight MyDataElement是一个320x200的图像,显示得很好,但是后面的字符串元素不显示,假设它在后面。因此,如果我将自

使用Monotouch 5.2.11 iOS

我遵循本教程,创建了一个带有图像的自定义单元格,并添加了IElementSizing界面。从未调用GetHeight

已经提出了类似的问题,普遍接受的解决方案是首先确保并创建根元素,在将它们添加到控制器之前设置rows=true。这不起作用。我尝试过这种方法,也尝试过将节添加到根元素的其他组合,但从未见过启动GetHeight

MyDataElement是一个320x200的图像,显示得很好,但是后面的字符串元素不显示,假设它在后面。因此,如果我将自定义单元格向上拖动到顶部上方,它将消失、重新出现,并且第二个stringelement将显示在其顶部

以下是我尝试过的代码:

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);

    }

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

我从github下载了Monotouch.Dialog来查看ImageLoader代码,并将其用作我项目中的参考。删除引用并使用内置的Monotouch.Dialog后,问题已得到解决。IElementSizing在github中不起作用:粘贴的文本不足以重现问题。但一般来说,Unlocarrows属性是自动计算的,设置它对YouTunks没有多大作用。当我从github下载的项目中删除Monolog.Dialog引用并使用内置的引用时,它被修复了。