c# - 从 UIViewController 派生的类中的 Monotouch Dialog 实现

标签 c# ios xamarin.ios selected monotouch.dialog

我只想覆盖 MonoTouch.Dialog 中的 Selected 方法。就这么简单,我想不出正确的方法..

我有一个派生自 UIViewController 的 FirstView 类。我在里面声明

DialogViewController viewController = new DialogViewController();

同样在这个类中,我用一个包含 UILabel 的部分填充 viewController。

现在我想对包含标签的行进行点击 - 我不想有一个按钮或其他带有事件的东西,我必须使用覆盖!

我知道这是一个相当简单的问题,但我就是做不对。

非常感谢!

最佳答案

如果您希望覆盖 MonoTouch.Dialog 中的方法,那么您需要定义自己的类型。这是自定义 MonoTouch.Dialog 的最佳方式(当事件不可用时)。

在这种情况下,Section 继承自 Element,其中定义了 Selected 方法。所以做这样的事情:

public class MySection : Section {
    public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
    {
        // do your own processing
    }
}

应该允许您在调用 Selected 时调用/执行您自己的代码。

关于c# - 从 UIViewController 派生的类中的 Monotouch Dialog 实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8803919/

相关文章:

c# - Xamarin iOS 上 Entity Framework Core 中的可空值

c# - SharpZipLib - ZipException "System.ArgumentOutOfRangeException"- 为什么我会收到此异常?

c# - Visual Studio 2010 程序集引用问题

c# - 在 Windows Phone 8.1(通用应用程序)中如何确定我连接的是 WiFi 还是移动网络?

java - sql 选择并插入已连接的项目,但我想全部显示

android - 在 Windows 官方 Meteor 上创建移动应用程序的最简单方法

ios 音频单元 remoteIO 在录制时播放

c# - 如何在 Xamarin Forms 中设置条目的顶部填充

ios - 为什么不是我的所有代码都在我的 findObjectsInBackgroundWithBlock :^ being executed?

ipad - 无法安装应用程序 iPad,但它可以在 Xamarin.Forms 的 iPhone 中运行