[MonoTouch] Sharing UIToolbar between ViewControllers?
Chris House
chrishouse at proag.com
Wed Mar 21 18:21:53 UTC 2012
Thanks Jeff. I actually came to that same conclusion shortly after I
sent my email, but I'm glad to have some validation of my approach as
I'm still quite new to MT. So far it seems to be working just like I'd
hoped it would. I do have two follow up questions on the actual
implementation:
First - right now in my UIToolbar subclass, I have a method that creates
the necessary UISegmentedControls and UIBarButtonItems then adds them to
the toolbar (this.SetItems(...)). I'm calling this method from my
UIToolbar subclass' constructor. Is that the right place to do this
kind of setup?
Second - Since my UISegmentedControls will need to respond to events, do
these need to be class level fields or can I just declare/instantiate
them in the method described above?
From: Jeff Stedfast [mailto:jeff at xamarin.com]
Sent: Wednesday, March 21, 2012 1:13 PM
To: Chris House
Cc: monotouch at lists.ximian.com
Subject: Re: [MonoTouch] Sharing UIToolbar between ViewControllers?
Hi Chris,
You could always write a new UIToolbar subclass that adds all of the
right items to itself. That's probably how I would do it.
Hope that helps,
Jeff
On Wed, Mar 21, 2012 at 1:52 PM, Chris House <chrishouse at proag.com>
wrote:
I'm currently developing an iPad app with MT. The general UI layout
consists of four screens, each with a UITabBarController at the bottom
of the screen. The UITabBarController will have four buttons each
pointing to a different view controller. At the top of each of these
four view controllers will be a UIToolbar. This UIToolbar will be
essentially the same on all four view controllers. It will have two
UISegmentedControls and a label that will need to change slightly
depending on the view controller currently being displayed.
My question is this: Considering that there is so much common behavior
and appearance to my UIToolbar, what is the best way to share this
across my four view controllers? Is the best option to just create some
function that constructs my UIToolbar and its associated controls and
then add that to the current view controller as a subview at runtime or
is there a better approach?
Thanks!
Chris
_______________________________________________
MonoTouch mailing list
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/20120321/52556463/attachment.html>
More information about the MonoTouch
mailing list