Monotouch:如何更新 AppDelegate 部分类中的文本字段? [英] Monotouch: How to update a textfield in AppDelegate partial class?
本文介绍了Monotouch:如何更新 AppDelegate 部分类中的文本字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文本字段(使用 IB 创建),它有一个连接到 App Delegate 的插座.可访问性已启用.
I have a textfield (created using IB) that has an outlet connected to App Delegate. Accessability is enabled.
我有一个 IAP 类,我需要在其中更新该文本字段.从我的代码中看不到它.
I have a class for IAP, where I need to update that textfield. It is not visible from my code.
我该怎么做?
推荐答案
这很简单,你需要做两件事:
This is pretty simple to do, you need to do 2 things:
public class AppDelegate : NSObject {
public UITextField PublicField {
get {
return outletName;
}
}
}
2:从另一个类访问您的 AppDelegate:
public class OtherClass : NSObject {
public void SomeMethod () {
var ad = (AppDelegate) UIApplication.SharedApplication.Delegate;
ad.PublicField.Text = "foo";
}
}
这篇关于Monotouch:如何更新 AppDelegate 部分类中的文本字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文