Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3721522
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:35:07+00:00 2026-05-19T05:35:07+00:00

I need to display a view modally. The viewcontroller that needs to be displayed

  • 0

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).

In the viewcontroller that presents the modal viewcontroller I have:

-(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];

}

MyModalViewController:

- (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];
}

The viewcontrollers in the array are just normal UIViewControllers.

I have set this property in those classes to:

self.navigationItem.hidesBackButton = YES;

My question: Is this the proper way to achieve a UITabBarController behavior?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T05:35:08+00:00Added an answer on May 19, 2026 at 5:35 am

    Haven’t tested it, but It looks good, except that popViewControllerAnimated. I’d use popToRootViewControllerAnimated instead (In case a controller uses itself the navigationController).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code in my view. I need to display the selected value
I need ability to display content in Hex View, like this from WinHex Offset
I need to display in image on the view this way <img src =
MFC doc/view architecture, GDI drawing/printing. I have a DIB backbuffer I need to display
I need to display a component view into a module. I have developed my
I have a View on which I need to display a date formatted in
I'm working on an app that will need to display a coverflow style view
I have one application. I need to display map view when we click on
I have one application. I need to display a map view when we click
I need to display a image view that is filled with violet color picture

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.