分类UIAlertView未显示

问题描述:

我是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); 
     } 
    } 

不知道(我需要测试进一步),但你的作品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); 
    } 
... 

希望能解除你:-)

+0

嗯。好的。谢谢。奇怪。为什么默认构造函数会工作而另一个不工作? – Krumelur

+0

我的猜测是,某些东西没有正确初始化(在那个调用链中),我对它有一个说明(我现在想要完成其他的事情;-)。您可以填写关于bugzilla.xamarin.com的错误报告,我(或其他人)将发布关于此问题的未来发现。否则(如果我的记忆不会让我失望),我会尝试将这些信息添加回我的答案中。 – poupou

+0

提交的错误http://bugzilla.xamarin.com/show_bug.cgi?id=1620 –