iphone - 如何修复自定义大小的 MonoTouch 对话框中 EntryElement 的滚动问题?

标签 iphone uitableview uiviewcontroller xamarin.ios monotouch.dialog

我做了一些与 this 非常相似的事情问题。我创建了一个 MonoTouch DialogViewController,其中有一堆 EntryElements,用于捕获用户注册的信息。然后我将此 DialogViewController 添加到另一个 UIViewController 中:

            registerDialog = new RegisterDialog (); // the dvc
            registerDialog.View.Frame = new RectangleF (0, 60, 320, View.Frame.Height - 60);
            registerDialog.TableView.BackgroundView = null; // make the background transparent
            Add (registerDialog.View);

当用户单击 EntryElement 时就会出现问题。键盘显示出来,对于前几个 EntryElements 一切都很好,因为键盘没有隐藏任何东西。当您在 EntryElements 中前进时,DialogViewController 不再滚动键盘上方的元素。基本上 DialogViewController 的滚动会中断。

这是由于将 DialogViewController 的 View 添加到另一个 View 中引起的。当正常将 DialogViewController 推到 UINavigationController 上时,它可以完美地工作:

NavigationController.PushViewController (new LoginScreen (), true);

这是一个错误还是我可以覆盖某些内容来修复滚动?

编辑

截图1: 带有一些 EntryElements 的 DialogViewController。我已向下滚动到底部 - 姓氏上方有更多 EntryElements。

enter image description here

截图2: 当我点击电子邮件条目元素时会发生什么。您可以非常清楚地看到 DVC 没有向上滚动表格 View ,而它通常会这样做。

enter image description here

最佳答案

您可以尝试对 DialogViewController 类进行子类化,而不是将 DialogViewController View 添加到另一个 View 中。如果你这样做的话,问题就会消失。我不知道这是否是一个好方法,但我在生产中成功地使用了它。这是我通常的做法,注意 RootElement 在基本构造函数中最初是空的,但我们在 ViewDidLoad 中添加内容。

public class MyController : DialogViewController
{
    public MyController() : base(new RootElement(""), true)
    {
    }

    public override void ViewDidLoad() 
    {
        var section1 = new Section("Credentials") 
        {
            new EntryElement("Username", null, null),
            new EntryElement("Password", null, null)
        };

        Root.Add(section1);
       // additional initialization here
    }
}

此外,如果您想在表单上方或下方添加内容,您可以向部分添加页眉和页脚 - Section 类的 HeaderView 和 FooterView 属性。

关于iphone - 如何修复自定义大小的 MonoTouch 对话框中 EntryElement 的滚动问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13484280/

相关文章:

ios - 以编程方式将单元格添加到 UITableView

ios - Swift - 如何关闭所有 View Controller 以返回根目录

ios - 如何在不同的 UIViewcontroller 之间切换

ios - HeightForRowAt indexPath 问题

iphone - iOS 如何有效地对 cgimage 执行旋转(最多 125 帧)?

iPhone 应用程序由于内存不足而崩溃,但在模拟器中运行良好

iphone - 左右扫视 View

ios - 使 UICollectionView 看起来像 UITableView

ios - 嵌入式 View Controller (Swift 3)中永远不会调用 addObserver 选择器函数

iphone - 带有 Nib 文件和继承的 UIViewController