我在这里使用的是最新版本的MT。在RightView中没有UITextField属性。看来是忘了绑定了。我能手动绑定吗?
解析-读到结束
编辑:多亏了杰夫,我走得更近了。使用LeftView (!)我让这段代码毫无问题地运行:
var _entry = new UITextField ();
UIButton oLeftButton = UIButton.FromType(UIButtonType.DetailDisclosure);
_entry.LeftView = oLeftButton;
_entry.LeftViewMode = UITextFieldViewMode.Always;使用手动绑定尝试使用RightView:
var _entry = new UITextField ();
UIButton oRightButton = UIButton.FromType(UIButtonType.DetailDisclosure);
Messaging.void_objc_msgSend_intptr (_entry.Handle, Selector.GetHandle ("setRightView:"), oRightButton.Handle);
// Code crashes here with a NULL ref in ObjC.
_entry.RightViewMode = UITextFieldViewMode.Always;和另一个编辑:在MT3.x中有一个bug,它将在MT4中修复,并在访问RightViewMode属性时导致崩溃。必须像这里演示的那样直接设置RightViewMode。
var _entry = new UITextField ();
UIButton oRightButton = UIButton.FromType(UIButtonType.DetailDisclosure);
// Set RightView directly.
Messaging.void_objc_msgSend_intptr (_entry.Handle, Selector.GetHandle ("setRightView:"), oRightButton.Handle);
// Set RightViewMode directly.
Messaging.void_objc_msgSend_int (_entry.Handle, Selector.GetHandle ("setRightViewMode:"), (int)UITextFieldViewMode.Always);发布于 2011-03-21 14:41:49
是的,这是错过了,它将修复在MonoTouch 4阿尔法3。
您可以像这样手动调用它:
Runtime.GetNSObject (Messaging.intptr_objc_msgSend (textField.Handle, Selector.GetHandle ("leftView")));https://stackoverflow.com/questions/5378531
复制相似问题