xamarin.ios - 单触摸DialogViewController刷新请求 "System.ArgumentException: You should set the handler before the controller is shown"

标签 xamarin.ios monotouch.dialog

我在让 RefreshRequested 事件在实现 DialogViewController 的 ViewController 之一中工作时遇到一些问题:

public CustomViewController () : base (null, true) {
        RefreshRequested += delegate {
        ...
        ReloadComplete ();
        };
    }

我从另一个 ViewController 调用 CustomViewController,如下所示:

var dvc = new CustomViewController();
this.ActivateController(dvc);

我收到的错误消息是“顶级异常:System.ArgumentException:您应该在显示 Controller 之前设置处理程序”

我在这里做什么有什么指示吗?谢谢

最佳答案

看起来您没有指定 RootElement,即您自己的构造函数将其设置为 null,因此您会收到警告,内部状态尚未准备好设置事件。

您应该使用构造函数创建一个空的RootElement,然后向其中添加内容(使用属性)。这应该允许您在自己的构造函数中设置事件。例如

public CustomViewController () : base (new RootElement (String.Empty), true)

Any pointers of what I am doing from here?

如有疑问,您总能看到整个 source code MonoTouch.Dialog 在它的 github 存储库中。

关于xamarin.ios - 单触摸DialogViewController刷新请求 "System.ArgumentException: You should set the handler before the controller is shown",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9369396/

相关文章:

c# - iOS换风口——Monotouch

c# - OwnerDrawnElement 背景颜色为黑色,直到被选中

ios - MonoTouch : MonoTouch. 对话框渲染标题

ios - 如何使用 outlets 和 IB 为表格 View 部分创建自定义标题 View

Firebase 消息传递导致 Xamarin iOS 崩溃

xamarin - 如何在默认程序中打开文件?

scroll - 在MonoTouch.DIalog中找不到如何向DialogControllerView添加滚动事件

c# - MonoTouch.Dialog 中的每个 RootElement 都有专用的 UIViewController 吗?

ios - 如何添加具有特定边界的空白 UIImageView 作为 UIStackView 的子级?

c# - 当我从 UITableViewSource 单击 RowSelected 时如何打开 UIViewController