[MonoTouch] Sharing UIToolbar between ViewControllers?

Jeff Stedfast jeff at xamarin.com
Wed Mar 21 18:39:34 UTC 2012


Hi Chris,

On Wed, Mar 21, 2012 at 2:21 PM, Chris House <chrishouse at proag.com> wrote:

> 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?
>

As good as any, I suppose. You could also do it in the ViewDidLoad() method
if you prefer to only keep the views around when they are needed. For
something like this, it probably doesn't matter.


> ****
>
> ** **
>
> 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?
>

I would probably declare them as class level fields.


Hope that helps,

Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/monotouch/attachments/20120321/c1d15443/attachment-0001.html>


More information about the MonoTouch mailing list