0
我使用MonoTouch.Dialog在Xamarin iOS应用程序中创建页面。Monotouch对话框 - 多行RootElement
我想通过利用GetCell方法创建一个多行RootElement。这可以在加载时正常工作,但是如果单击另一个选项卡并返回,元素将缩回到默认大小(同样,当您单击看到的元素时,它会在缩小之前缩小)。
我已经试过与UnevenRows混乱,迄今没有成功。
public partial class TestController : UITabBarController
{
public TestController()
: base("TestController", null)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
var navController = new UINavigationController
{
Title = "Test1"
};
navController.PushViewController(new TestDialogViewController(), false);
ViewControllers = new[]
{
navController,
new UIViewController
{
Title = "Test2"
},
};
}
}
public class TestDialogViewController : DialogViewController
{
public TestDialogViewController() : base(new RootElement("Test"))
{
Root.UnevenRows = true; // has no effect
var testSection = new Section("Test section");
var testChildRootElement = new CustomRootElement("Multi\nLine\nElement")
{
UnevenRows = true // has no effect
};
var testChildSection = new Section("Test child section");
var testEntryElement = new EntryElement(string.Empty, string.Empty, "Test entry element");
testChildSection.Add(testEntryElement);
testChildRootElement.Add(testChildSection);
testSection.Add(testChildRootElement);
Root.Add(testSection);
}
}
public class CustomRootElement : RootElement
{
public CustomRootElement(string caption) : base(caption) {}
public override UITableViewCell GetCell(UITableView tv)
{
var cell = base.GetCell(tv);
// Setup Multi-line Element
cell.TextLabel.LineBreakMode = UILineBreakMode.WordWrap;
cell.TextLabel.Lines = 0;
return cell;
}
}