But if we are talking UINavigationController and a iOS 5.0+ update to the UINavigationController then I can't cast it to a special interface, and I can't (as we have seen below) inherit from UINavigationController, and then implement a special interface..
So really, in this case there isn't an equivalent usecase.. I hate pinning code to a version, but it looks like I'll actually have to query the device's OS version and have two code paths accordingly (for the given task).. So really, there is no "MonoTouch" way to style the Navigation Control (beyond color) pre iOS 5.0? Hurm, thats a bummer. Josh ________________________________ From: Christopher Hatton [[email protected]] Sent: Thursday, March 15, 2012 1:35 PM To: [email protected] Subject: Re: [MonoTouch] Now that I can post : Extending the UINavigationController?? The C# way would be to have an interface, e.g. IBlah, which specifies the method call ('selector') which you want to check. Then check using 'is' or 'as', as below: if (object is IBlah) or IBlah myTest = originalObject as IBlah if (myTest != null) { ... } // Do stuff with my test The second way is often preferable if you have an immediate use for your object, because the cast has already been done for you implicity. - Chris On 15 March 2012 18:26, [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>> wrote: Sadly nope, client needs this app to run on as many devices as possible. What is the MonoTouch equivalent of respondsToSelector: ? Thanks Josh ________________________________________ From: Nic Wise [[email protected]<mailto:[email protected]>] Sent: Thursday, March 15, 2012 11:56 AM To: [email protected]<mailto:[email protected]> Cc: Jason Awbrey; MonoTouch Forums Subject: Re: [MonoTouch] Now that I can post : Extending the UINavigationController?? Can you be iOS5 only (well, fall back is using a tint color for older ones)?? if so: UINavigationBar.Appearance.SetBackgroundImage(Resources.NavBarHeaderBackground, UIBarMetrics.Default); Works perfectly for me :) And I put an iOS check around the calls, so it just defaults back to a tint color on iOS 4.2 On Thu, Mar 15, 2012 at 16:40, [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>> wrote: > 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 [[email protected]<mailto:[email protected]>] > Sent: Thursday, March 15, 2012 11:25 AM > To: [email protected]<mailto:[email protected]> > 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, [email protected]<mailto:[email protected]> > <[email protected]<mailto:[email protected]>> > 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 >> [email protected]<mailto:[email protected]> >> http://lists.ximian.com/mailman/listinfo/monotouch > > > > _______________________________________________ > MonoTouch mailing list > [email protected]<mailto:[email protected]> > http://lists.ximian.com/mailman/listinfo/monotouch > -- Nic Wise t. +44 7788 592 806<tel:%2B44%207788%20592%20806> | @fastchicken | http://www.linkedin.com/in/nicwise b. http://www.fastchicken.co.nz/ Nearest Bus: find when the next bus is coming to your stop. http://goo.gl/Vcz1p mobileAgent (for FreeAgent): get your accounts in your pocket. http://goo.gl/IuBU Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2 _______________________________________________ MonoTouch mailing list [email protected]<mailto:[email protected]> http://lists.ximian.com/mailman/listinfo/monotouch
_______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
