[MonoTouch] Programmatically creating a TabViewController

Geoff Norton gnorton at novell.com
Wed Aug 26 15:16:14 EDT 2009


Ethan,

   Have you seen bug http://bugzilla.novell.com/show_bug.cgi?id=533566

I'm guessing the way you have set the nibs in method #1 is the same,  
causing your issues there.

#2 appears to be an oversight.  I've added UITabBarController.Item  
into the next release.  Thanks.

-g

On 26-Aug-09, at 2:34 PM, Ethan Nagel wrote:

> There seems to be a lot of confusion around how to make the  
> UITabViewController work in MonoTouch.   I'm an experienced iPhone  
> developer and I've tried two approaches without success:
> Creating the UITabViewController in a NIB file, with a separate NIB  
> for each tab.   This might actually be workable if you manually edit  
> the designer file that contains the UITabViewController and remove  
> the extra Register attributes that are created.
> Programmatically creating a UITabViewcontroller and attaching an  
> array of UIViewControllers for each tab.  While this does partially  
> work (the tabs show up), there appears to be no way to attach images  
> to the tab because tabBarItem property has not been implemented in  
> UIViewController.
> Perhaps someone could post a working example a UITabViewController- 
> based application.  (One with a NIB file for each tab is  
> prefereable.  I suspect you could make something work in a single  
> NIB file, but this is not very workable in the real-world.)
>
> - Ethan
>
> On Wed, Aug 26, 2009 at 11:17 AM, Phil Jepsen <jepsen at gmail.com>  
> wrote:
> This tutorial from Stanford may help:
>
> http://www.stanford.edu/class/cs193p/downloads/07-NavigationTabBarControllers.pdf
>
> Tab Bar Appearance
> • View controllers can define their appearance in the tab bar
> • UITabBarItem
> ! Title + image or system item
> • Each view controller comes with a tab bar item for customizing
>
> Page 41.
>
> Cheers,
>
> Phil Jepsen
>
>
>
> On Wed, Aug 26, 2009 at 10:06 AM, Tim Scott <tscott at lunaversesoftware.com 
> > wrote:
> I don't understand.  UITabBarController does not have tabBarItem.   
> Are you
> talking about something like this:
>
> tabBarController.TabBar.Items[0] = new
> UITabBarItem(UITabBarSystemItem.Favorites, 1);
>
> This does not seem to work, and besides it seems wrong.  Because the  
> tabs
> are set via UITabBarController.SetViewControllers method I would  
> expect that
> each UIViewController passed into this method should specify its own  
> tab as
> it does in Obj C.
>
>
>
> On 8/26/09 10:23 AM, "Geoff Norton" <gnorton at novell.com> wrote:
>
> > Use UITabBarController not UIViewController, as this is the actually
> > controller type for a UITabBar :)
> >
> > -g
> >
> > On 26-Aug-09, at 11:17 AM, Tim Scott wrote:
> >
> >> Ethan,
> >>
> >> Did you ever figure this out?  I have been watching the Stanford
> >> series on
> >> IPhone programming, and it shows setting tab bars items for a view
> >> controllers just as you say.  That is, in ObjC, you assign
> >> UIViewControler.tabBarItem a UITabBarItem instance.  In MonoTouch,
> >> there is
> >> no like property or method that I can see.  How do you set the  
> image
> >> for
> >> each tab programmatically in MonoTouch?
> >>
> >> Tim
> >>
> >> On 8/24/09 5:16 PM, "monotouch-request at lists.ximian.com"
> >> <monotouch-request at lists.ximian.com> wrote:
> >>
> >>> Ok, let me make sure I understand things correctly.  I'm  
> creating a
> >>> UITabBarController which is a container for my tabs.   Each Tab is
> >>> essentially an implementation of UIViewController with the  
> tabBarItem
> >>> property set to have the details of how the tab should be
> >>> displayed.  (I'm
> >>> setting this using the UITabBarController.ViewControllers property
> >>> to an
> >>> array of my View Controllers.)  The problem I'm having is that
> >>> there is *no
> >>> tabBarItem property available in UIViewController*, which is what
> >>> I'm used
> >>> to from ObjC land.  Am I on the right track here, or am I missing
> >>> something?
> >>>
> >>> - Ethan Nagel
> >>>  President, Nagel Technologies, Inc.
> >>>  enagel at nageltech.com
> >>>  http://www.nageltech.com
> >>>  (c) 831.247.5702
> >>>
> >>>
> >>> On Mon, Aug 24, 2009 at 11:21 AM, Geoff Norton  
> <gnorton at novell.com>
> >>> wrote:
> >>>
> >>>> You're looking for UITabBarController, rather than a regular
> >>>> UIViewController.
> >>>>
> >>>> -g
> >>>>
> >>>> On 24-Aug-09, at 3:48 AM, Ethan Nagel wrote:
> >>>>
> >>>> I've got an open question on creating a TabViewController using
> >>>> Interface
> >>>>> Builder, but in the mean time I was wondering if someone could
> >>>>> guide me in
> >>>>> creating a TabViewController programatically.  I can create the
> >>>>> TabViewController, but there is no "tabBarItem" property in
> >>>>> UIViewController
> >>>>> to allow me to configure each tab.  I tried creating the
> >>>>> UITabBarItem and
> >>>>> assigning it to "tabBarItem" using
> >>>>> UIViewController.SetNativeField, but that
> >>>>> didn't seem to have any effect.
> >>>>>
> >>>>> - Ethan
> >>>>> _______________________________________________
> >>>>> MonoTouch mailing list
> >>>>> MonoTouch at lists.ximian.com
> >>>>> http://lists.ximian.com/mailman/listinfo/monotouch
> >>>>>
> >>>>
> >>>>
> >>
> >>
> >> _______________________________________________
> >> MonoTouch mailing list
> >> MonoTouch at lists.ximian.com
> >> http://lists.ximian.com/mailman/listinfo/monotouch
> >
>
>
> _______________________________________________
> MonoTouch mailing list
> MonoTouch at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monotouch
>
>
>
> _______________________________________________
> MonoTouch mailing list
> MonoTouch at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monotouch
>
>
> _______________________________________________
> 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/mailman/private/monotouch/attachments/20090826/741db3fd/attachment-0001.html 


More information about the MonoTouch mailing list