[MonoTouch] Cannot inherit from UIAlertView

ayoung andrewdyoung at gmail.com
Thu Oct 20 23:02:36 EDT 2011


 Done! http://bugzilla.xamarin.com/show_bug.cgi?id=1620 


On Thursday, October 20, 2011 at 16:22, Sebastien Pouliot [via MonoTouch] wrote:

>  Hello Andrew, 
> 
> This was asked on stackoverflow [1] recently. The workaround is to 
> override only the default constructor and use the properties to set 
> all values. 
> 
> Not sure (yet) about the root cause, it's on my TODO but I got other 
> bugs (without workarounds) to go thru before that. 
> 
> Feel free to open a bug report (less chance that I forget about it ;-) 
> Sebastien 
> 
> [1] http://stackoverflow.com/questions/7692522/subclassed-uialertview-not-shown
> 
> On Thu, Oct 20, 2011 at 5:07 PM, Andrew Young <[hidden email] (/user/SendEmail.jtp?type=node&node=3923805&i=0)> wrote: 
> 
> > App crashes when I try to inherit from UIAlertView. See stack trace and 
> > sample code below. MonoTouch 5.0. 
> > Any ideas? I have a sample app that shows this for anyone interested. 
> > public class ViewController : UIViewController 
> > { 
> >   private DateTimePickerView _pickerView; 
> >   public ViewController () 
> >   { 
> >   } 
> >   public override void ViewDidLoad () 
> >   { 
> >     base.ViewDidLoad (); 
> >     new NotReachableAlertView ().Show (); 
> >   } 
> > } 
> > public class NotReachableAlertView : UIAlertView 
> > { 
> >   public NotReachableAlertView() : base("Title", "Message", null, "Cancel") 
> >   { 
> >   } 
> > } 
> > Unhandled Exception: MonoTouch.Foundation.MonoTouchException: Objective-C 
> > exception thrown.  Name: NSInternalInconsistencyException Reason: Requesting 
> > the window of a view (<PickerViewCrash.NotReachableAlertView: 0x79a700; 
> > 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:. 
> >   at MonoTouch.UIKit.UIAlertView.Show () [0x00000] in <filename unknown>:0 
> >   at PickerViewCrash.ViewController.ViewDidLoad () [0x00006] in 
> > /Users/Andrew/Projects/PickerViewCrash/ViewController.cs:20 
> >   at MonoTouch.UIKit.UIWindow.MakeKeyAndVisible () [0x00000] in <filename 
> > unknown>:0 
> >   at PickerViewCrash.AppDelegate.FinishedLaunching 
> > (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary 
> > options) [0x00031] in 
> > /Users/Andrew/Projects/PickerViewCrash/AppDelegate.cs:32 
> >   at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String 
> > principalClassName, System.String delegateClassName) [0x00000] in <filename 
> > unknown>:0 
> >   at PickerViewCrash.Application.Main (System.String[] args) [0x00000] in 
> > /Users/Andrew/Projects/PickerViewCrash/Main.cs:16 
> > [ERROR] FATAL UNHANDLED EXCEPTION: MonoTouch.Foundation.MonoTouchException: 
> > Objective-C exception thrown.  Name: NSInternalInconsistencyException 
> > Reason: Requesting the window of a view 
> > (<PickerViewCrash.NotReachableAlertView: 0x79a700; 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:. 
> >   at MonoTouch.UIKit.UIAlertView.Show () [0x00000] in <filename unknown>:0 
> >   at PickerViewCrash.ViewController.ViewDidLoad () [0x00006] in 
> > /Users/Andrew/Projects/PickerViewCrash/ViewController.cs:20 
> >   at MonoTouch.UIKit.UIWindow.MakeKeyAndVisible () [0x00000] in <filename 
> > unknown>:0 
> >   at PickerViewCrash.AppDelegate.FinishedLaunching 
> > (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary 
> > options) [0x00031] in 
> > /Users/Andrew/Projects/PickerViewCrash/AppDelegate.cs:32 
> >   at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String 
> > principalClassName, System.String delegateClassName) [0x00000] in <filename 
> > unknown>:0 
> >   at PickerViewCrash.Application.Main (System.String[] args) [0x00000] in 
> > /Users/Andrew/Projects/PickerViewCrash/Main.cs:16 
> > Terminating runtime due to unhandled exception 
> > 
> > _______________________________________________ 
> > MonoTouch mailing list 
> > [hidden email] (/user/SendEmail.jtp?type=node&node=3923805&i=1) 
> > http://lists.ximian.com/mailman/listinfo/monotouch
> > 
> > _______________________________________________ 
> MonoTouch mailing list 
> [hidden email] (/user/SendEmail.jtp?type=node&node=3923805&i=2) 
> http://lists.ximian.com/mailman/listinfo/monotouch
> 
> 
> If you reply to this email, your message will be added to the discussion below: http://monotouch.2284126.n4.nabble.com/Cannot-inherit-from-UIAlertView-tp3923431p3923805.html 
>  To start a new topic under MonoTouch, email ml-node+s2284126n3346893h90 at n4.nabble.com (mailto:ml-node+s2284126n3346893h90 at n4.nabble.com) 
>  To unsubscribe from MonoTouch, click here (http://monotouch.2284126.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3346893&code=YW5kcmV3ZHlvdW5nQGdtYWlsLmNvbXwzMzQ2ODkzfDE5MjczODc4ODI=). 



--
View this message in context: http://monotouch.2284126.n4.nabble.com/Cannot-inherit-from-UIAlertView-tp3923431p3924180.html
Sent from the MonoTouch mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monotouch/attachments/20111020/711042ac/attachment-0001.html 


More information about the MonoTouch mailing list