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

  • Home
  • SEARCH
  • 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 6608399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:36:20+00:00 2026-05-25T19:36:20+00:00

I try to present a modal view (InfoViewController) from a navigation view controller(DateViewController). I

  • 0

I try to present a modal view (InfoViewController) from a navigation view controller(DateViewController).

I add a toolbar on top of InfoViewContoller’s view. Now I want to add a title “Info” and a “Done” button on the toolbar.(The Done button will perform the infoDismissAction method)

Can anyone give me som tips? Thanks a lot!

Here’s code of DateViewController.h

#import <UIKit/UIKit.h>
#import "InfoViewController.h"
@interface DateViewController : UIViewController 
{
    InfoViewController *infoViewController;
}
@property (nonatomic, retain) InfoViewController *infoViewController;
@end

DateViewController.m

- (IBAction)modalViewAction:(id)sender{    
    if (self.infoViewController == nil)
        self.infoViewController = [[[InfoViewController alloc] initWithNibName:
                                   NSStringFromClass([InfoViewController class]) bundle:nil] autorelease];
    [self presentModalViewController:self.infoViewController animated:YES];
}

- (void)dealloc{
    if (self.infoViewController != nil)
    {
        [infoViewController release];
    }
    [super dealloc];
}

- (void)viewDidLoad{
    self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Info"  style:UIBarButtonSystemItemPlay target:self  action:@selector(modalViewAction:)] autorelease];
    [modalBarButtonItem release];
    [super viewDidLoad];
}

Here’s InfoViewController.m

- (IBAction)infoDismissAction:(id)sender{
    [self.parentViewController dismissModalViewControllerAnimated:YES];
}

- (void)viewDidLoad {
    UIToolbar *toolBar;
    toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
    toolBar.frame = CGRectMake(0, 0, 320, 50);
    toolBar.barStyle = UIBarStyleDefault;
    [toolBar sizeToFit];        
    [self.view addSubview:toolBar]; 
    [toolBar release];
    [backButton release];
    [super viewDidLoad];
}
  • 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-25T19:36:20+00:00Added an answer on May 25, 2026 at 7:36 pm

    Try this code.

    - (void)viewDidLoad {
           UIToolbar *toolBar;
                toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
                toolBar.frame = CGRectMake(0, 0, 320, 50);
                toolBar.barStyle = UIBarStyleDefault;
                [toolBar sizeToFit];      
    UIBarButtonItem *flexibleSpace = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease];
    UIBarButtonItem *infoButton = [[[UIBarButtonItem alloc] initWithTitle:@"INFO" style:UIBarButtonItemStyleBordered target:self action:@selector(InfoAction:)] autorelease];
    UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"DONE" style:UIBarButtonItemStyleBordered target:self action:@selector(doneAction:)];
    
    
                NSArray *barButton  =   [[NSArray alloc] initWithObjects:flexibleSpace,infoButton,flexibleSpace,doneButton,nil];
                [toolBar setItems:barButton];
    
            [self.view addSubview:toolBar];
            [toolBar release];
            [barButton release];
            barButton = nil;
            [super viewDidLoad];
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

    I am having an issue dismissing a modal view controller on a certain edge
I try to add an addons system to my Windows.Net application using Reflection; but
We try to convert from string to Byte[] using the following Java code: String
here is the code private ResultSet rsResult; try { rsResult = DBProcess.statement.executeQuery(SELECT * FROM
When I try to run a .NET assembly ( boo.exe ) from a network
In my iOS application, I want to provide a settings-view. presentModalViewController works very well:
Greetings! Here's the scenario. Starting with a navigation controller (and no tab bar is
I'll try to present my problem clearly, but I'm bit of a novice in
I have an example web solution that I downloaded and when I try Add
I have rotation problem on UISplitViewController . In my case, after calling present modal

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.