UIToolbar and UINavigationController
<p>I need to display a view modally. The viewcontroller that needs to be displayed modally has to have a UIToolbar at the bottom. In this toolbar there are one uisegmentedcontroller with three elements. (Think of an tabbar).</p>

<p>In the viewcontroller that presents the modal viewcontroller I have:</p>

<pre><code>-(IBAction)presentModally:(id)sender {  

if (self.nvc == nil) {
    MyModalViewController *vc = [[MyModalViewController alloc] init];
    UINavigationController *navvc = [[UINavigationController alloc] initWithRootViewController:vc];
    navvc.navigationItem.prompt = @"";
    navvc.navigationBar.barStyle = UIBarStyleBlack;
    [vc release];
    self.nvc = navvc;
    [navvc release];
}

[self presentModalViewController:self.nvc animated:YES];
</code></pre>

<p>}</p>

<p><strong>MyModalViewController:</strong></p>

<pre><code>- (void)loadView {
[super loadView];

UIView *uiview = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 460.0f)];
uiview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.view = uiview;
[uiview release];

UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0f, 436.0f, 320.0f, 44.0f)];
toolbar.barStyle = UIBarStyleBlack;
toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth;

NSArray *itemArray = [NSArray arrayWithObjects: @"One", @"Two", @"Three", nil];
UISegmentedControl *segCon = [[UISegmentedControl alloc] initWithItems:itemArray];
segCon.frame = CGRectMake(60, 4, 200, 36);
segCon.segmentedControlStyle = UISegmentedControlStyleBar;
segCon.tintColor = [UIColor darkGrayColor];
segCon.selectedSegmentIndex = 0;
[segCon addTarget:self action:@selector(changedSegment:) forControlEvents:UIControlEventValueChanged];

[toolbar addSubview:segCon];
self.segmentedControl = segCon;
[segCon release];

[[self navigationController].view addSubview:toolbar];
[toolbar release];
}


- (void)changedSegment:(id)sender {

UISegmentedControl *control = (UISegmentedControl *)sender;
int index = control.selectedSegmentIndex;

[[self navigationController] popViewControllerAnimated:NO];
[[self navigationController] pushViewController:[self.controllers objectAtIndex:index] animated:NO];
}
</code></pre>

<p>The viewcontrollers in the array are just normal UIViewControllers. </p>

<p>I have set this property in those classes to:</p>

<pre><code>self.navigationItem.hidesBackButton = YES;
</code></pre>

<p>My question: Is this the proper way to achieve a UITabBarController behavior?</p>
