我有一个标准的DialogViewControler,它添加了一个带有View的Section作为构造函数:
Section sec = new Section (new LogoHeaderView (320, 87));
在LogoHeaderView中,我添加一个MT.Dialog GlassButton
btnContact = new GlassButton (frameContact);
btnContact.SetTitle ("Contact", UIControlState.Normal);
btnContact.NormalColor = Settings.ButtonNormalColor;
btnContact.HighlightedColor = Settings.ButtonHighlightColor;
btnContact.Tapped += (obj) => {};
btnContact.Enabled=true;
AddSubview (btnContact);
视图呈现效果很好,但是该按钮不可单击,并且Tapped事件永远不会激活.好像没有启用?
如何使GlassButton出现在Section的View中并像按钮一样工作?
解决方法:
这个对我有用.但是,如果您的GlassButton不在UIView限制之内,它将不会收到点击事件(这是UIView的问题,而不是GlassButton的问题).
例如.这行不通
UIView view = new UIView (new RectangleF (0, 0, 200, 10));
view.MultipleTouchEnabled = true;
GlassButton gb = new GlassButton (new RectangleF (10,10,100,100));
gb.SetTitle ("Contact", UIControlState.Normal);
gb.Enabled = true;
gb.Tapped += delegate {
Console.WriteLine ("hello");
};
view.AddSubview (gb);
但将第一行更改为:
UIView view = new UIView (new RectangleF (0, 0, 200, 200));
然后您可以单击该按钮.