gpt4 book ai didi

c# - 未显示子类 UIAlertView

转载 作者:行者123 更新时间:2023-11-30 17:15:53 24 4
gpt4 key购买 nike

我正在子类化 UIAlertView。请参阅下面的代码。没什么特别的,如果显示警报,只需设置一些 bool 值,如果警报被关闭,则将其重置。但警报从未出现在屏幕上。屏幕变暗,仅此而已。我在应用程序输出中收到以下消息:

Requesting the window of a view (<TestApp.AlertView: 0xfad7160; baseClass = UIAlertView; frame = (0 0; 0 0); transform = [0, 0, 0, 0, 0, 0]; alpha = 0; opaque = NO; layer = (null)>) with a nil layer. This view probably hasn't received initWithFrame: or initWithCoder:.

这条消息想告诉我什么?我调用基地。我还能做什么?这是类(class):

public sealed class AlertView : UIAlertView
{
public AlertView (string title, string message,UIAlertViewDelegate del, string cancelButtonTitle, params string[] otherButtons) : base(title, message, del, cancelButtonTitle, otherButtons)
{
}

public AlertView() : base()
{
}

public AlertView(NSCoder coder) : base(coder)
{
}

public AlertView(IntPtr handle) : base(handle)
{
}


public AlertView(NSObjectFlag t) : base(t)
{
}

public override void Show ()
{
this.bIdleTimerWasRunning = AppDelegateBase.MainApplication.IsUIIdleTimerEnabled;
AppDelegateBase.MainApplication.EnableUIIdleTimer(false);
base.Show ();
}

private bool bIdleTimerWasRunning;

public override void DismissWithClickedButtonIndex (int index, bool animated)
{
AppDelegateBase.MainApplication.EnableUIIdleTimer(this.bIdleTimerWasRunning);
base.DismissWithClickedButtonIndex (index, animated);
}
}

最佳答案

不确定(我需要进一步测试)但是您的 AlertView 的默认构造函数有效(出现无文本、无按钮的小弹出窗口)。

从那里你可以伪造整个事情,比如:

public sealed class AlertView : UIAlertView
{
public AlertView (string title, string message,UIAlertViewDelegate del, string cancelButtonTitle, params string[] otherButtons)
: base ()
{
Title = title;
Message = message;
Delegate = del;
// add buttons
CancelButtonIndex = AddButton (cancelButtonTitle);
foreach (string s in otherButtons)
AddButton (s);
}
...

希望这可以解除你的封锁:-)

关于c# - 未显示子类 UIAlertView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7692522/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com