The examples I have found for using a UITabBarController use the tab bar as
the sole means of navigating from that view -- the tab bar in effect is the
view (and whatever it displays as a result of a button being tapped). 

But let's say that I have a MainViewController (a UIViewController) that has
some buttons at the top part of the screen, a UITableView in the middle. At
the bottom of the screen I want to have a tab bar with some buttons that,
when tapped, bring up a new view, with the idea that the user can then tap
the "Back" button on the nav bar of the new views to return again to the
MainViewController. 

Following the Xamarin example, I wrote a TabBarController (a
UITabBarController) class file and put the code to set up the tab bar and
its functionality in that class' constructor. Back in my
MainViewController's ViewDidLoad I added the following code: 

mainTabBar = new TabBarController ();
mainTabBar.View.Frame = new RectangleF (0, tabbarVert,
this.View.Frame.Width, tabbarHeight);

That code compiles without any errors or warnings, as does my
TabBarController class file. So far, so good.

To add the tab bar to my MainViewController's view, I added the following
code: 

this.View.AddSubview (mainTabBar);

When I compile, this generates a couple of errors: 

"Error CS1502: The best overloaded method match for
`MonoTouch.UIKit.UIView.AddSubview(MonoTouch.UIKit.UIView)' has some invalid
arguments (CS1502)"

And: 

"Error CS1503: Argument `#1' cannot convert `SaleSitesb5.TabBarController'
expression to type `MonoTouch.UIKit.UIView' (CS1503)"

I tried making my TabBarController class a UITabBar instead of a
UITabBarController, although I couldn't find any examples online of anyone
doing that, but when I compile I get an error message because UITabBar
doesn't have a ViewControllers member, and I assume that without that
ViewControllers the tab bar won't function properly. 

So how I can create a tab bar and add it to my MainViewController and have
it function properly? 


--Chris


--
View this message in context: 
http://monotouch.2284126.n4.nabble.com/Problem-Adding-a-Tab-Bar-to-My-Main-View-tp4655417.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to