Are you adding your view controller manually to the UITabBar if so have you wrapped your view controller in a navigation controller?
My class derives from UITabBarController in it I...
List<UIViewController> navs = new List<UIViewController>();
int idx = 0;
foreach (IMenuItem i in menuItems)
{
var vc = i.ViewController;
var nc = new UINavigationController(vc);
if (vc is DesktopViewController)
{
((DesktopViewController)vc).ActionPerformed += ObjectActionPerformed;
}
nc.NavigationBar.BarStyle = UIBarStyle.Black;
navs.Add(nc);
idx++;
}
this.ViewControllers = navs.ToArray();
The important line is in bold otherwise in your vc this.NavigationController ==
null
D
David Black
Technical Manager (Web projects)
Casewise Systems Ltd | www.casewise.com<http://www.casewise.com/>
+44 1923 830300 office
+44 1923 830270 direct
64 Clarendon Road, Watford WD17 1DA
[cid:[email protected]]<http://www.facebook.com/casewise#!/pages/Casewise/471345470297>[cid:[email protected]]<http://www.linkedin.com/company/16238?trk=saber_s000001e_1000>[cid:[email protected]]<http://twitter.com/#!/casewise>[cid:[email protected]]<http://www.youtube.com/user/CasewiseLimited?blend=1&ob=5>
"When You Can See More, You Can Do More!"
[cid:[email protected]]
<http://www.casewise.com/products/communicator>
From: [email protected]
[mailto:[email protected]] On Behalf Of Dean Harry
Sent: 19 September 2011 07:41
To: [email protected]
Subject: [MonoTouch] UINavigationControllers inside UITabBarController
Hi All,
I am struggling to get my head around something and make it work, if anyone
could give me a quick 101 it would be great!
What I am trying to do is have my main screen as a TabBarController which has 3
NavigationControllers in it, each one pushing their own respective view
hierarchies upon user selection.
I am more familiar with using IB than coding screens by hand...
I can get the main screen working no problems, add 3 nav controllers and set
their NIB names and Classes to my view class names in IB, that works and the
correct views come up when selected.
My problem is pushing the next view onto the controller...
Example: controller 2 has a view with a tableview in it, the user selects a row
in the table and then I want it to push another view relevant to what the user
selected.
Every time I try to push it, it crashes with Object reference not set to an
instance of an object.
I think my problem is that I don't know how to reference the
NavigationController inside the TabBarController
Can anyone help out?
Thanks
Dean
<<inline: image001.jpg>>
<<inline: image002.jpg>>
<<inline: image003.jpg>>
<<inline: image004.jpg>>
<<inline: image005.jpg>>
_______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
