未显示子类 UIAlertView
我正在对 UIAlertView 进行子类化。请参阅下面的代码。没什么特别的,只需在显示警报时设置一些布尔值,并在警报消失时重置它。但警报永远不会出现在屏幕上。屏幕变暗,仅此而已。我在应用程序输出中收到以下消息:
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:.
此消息想告诉我什么?我正在给基地打电话。我还能做什么? 这是课程:
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);
}
}
I'm subclassing UIAlertView. See code below. Nothing fancy, just set some bool if the alert is shown and reset it if it gets dismissed. But the alert never apepars on sreen. The screen gets dimmed and that's it. I get the following message in the app output:
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:.
What does this message want to tell me? I'm calling base. What more can I do?
Here's the 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);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定(我需要进一步测试),但是
AlertView
的默认构造函数有效(出现小的无文本、无按钮的弹出窗口)。从那里你可以用类似的东西伪造整个事情:
希望这可以解锁你:-)
Not sure (I need to test that further) but the default constructor for your
AlertView
works (small text-less, button-less popup appear).From that you can fake the whole thing with something like:
Hopefully that can unblock you :-)