[MonoTouch] Now that I can post : Extending the UINavigationController??

jhandel at gmail.com jhandel at gmail.com
Thu Mar 15 16:40:30 UTC 2012


Ok, so in Objectionable C I could Swizzle my way into replacing the background of a NavigationBar inside a NavigationController (since the NavigationBar is read only, I can't replace it either :-P)..

The technique I used to use can be found here http://sebastiancelis.com/2009/12/21/adding-background-image-uinavigationbar/

What is a MonoTouch appropriate way to place a custom background image in the Navigation Bar of a NavigationController?

because swizzling is right out :-P

Thanks
Josh
________________________________
From: Jason Awbrey [jason at awbrey.net]
Sent: Thursday, March 15, 2012 11:25 AM
To: jhandel at gmail.com
Cc: MonoTouch Forums
Subject: Re: [MonoTouch] Now that I can post : Extending the UINavigationController??


Apple does not recommend subclassing the Nav controller

http://stackoverflow.com/questions/3029959/steps-in-subclassing-uinavigationcontroller

On Thu, Mar 15, 2012 at 11:23 AM, jhandel at gmail.com<mailto:jhandel at gmail.com> <jhandel at gmail.com<mailto:jhandel at gmail.com>> wrote:
Howdy all,
  Is there a known reason why inheriting UINavigationController would not work the same as directly using the UINavigationController?

this very simple class below (with the constructors just passing to the base and doing nothing else) loads a blank (black) screen.. where as directly creating a UINavigationController works just fine..

public class MyNavViewControllerBase: UINavigationController
   {
       public MyNavViewControllerBase (UIViewController viewController):base(viewController)
       {
           //setBackground(this);
       }

       public MyNavViewControllerBase (NSCoder coder):base(coder)
       {
           //setBackground (this);
       }

       public MyNavViewControllerBase ():base()
       {
           //setBackground (this);
       }

       public MyNavViewControllerBase (IntPtr ptr):base(ptr)
       {
           //setBackground (this);
       }

       public MyNavViewControllerBase (NSObjectFlag flag):base(flag)
       {
           //setBackground (this);
       }

       public MyNavViewControllerBase (string nibName, NSBundle bundle):base(nibName,bundle)
       {
           //setBackground (this);
       }
}

We are initializing our UINavigationController in code in our AppDelegate so there isn't an issue with the NIB here. Ergo

UINavigationController myNavController = new UINavigationController(myfirstViewController);

works fine but

MyNavViewControllerBase myNavController = new MyNavViewControllerBase(myfirstViewController);

just shows a black screen.


Thanks
Josh

_______________________________________________
MonoTouch mailing list
MonoTouch at lists.ximian.com<mailto:MonoTouch at lists.ximian.com>
http://lists.ximian.com/mailman/listinfo/monotouch

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/monotouch/attachments/20120315/6efa42e0/attachment.html>


More information about the MonoTouch mailing list