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 7029745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:34:44+00:00 2026-05-28T00:34:44+00:00

I want is on main window to present the created modalViewController view when the

  • 0

I want is on main window to present the created modalViewController view when the infobutton is pressed. But when I press Info button on the main window nothing happens.

In the mainviewcontroller.h file I have following code:

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>

@interface imageviewViewController : UIViewController{
AVAudioPlayer *audioPlayer;
}

@property (nonatomic, retain) UIToolbar *toolbar;
@property (nonatomic, assign) UIBarButtonSystemItem currentSystemItem;
@property (nonatomic, retain) AVAudioPlayer *audioPlayer;

@end

In the mainviewcontroller.m file have following code:

#import "imageviewViewController.h"
#import "Infoviewcontroller.h"


@implementation imageviewViewController

@synthesize toolbar;
@synthesize currentSystemItem;
@synthesize audioPlayer;

UIBarButtonItem *infoItem = [[UIBarButtonItem alloc] 
                          initWithTitle:@"Info" 
                          style:UIBarButtonItemStyleBordered 
                          target:nil 
                          action:@selector(Infobuttonpressed)]; 

  // flex item used to put space in between buttons

    UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] 
                             initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
                             target:nil
                             action:nil];

    //Add buttons to the array

    NSArray *toolbarItems = [NSArray arrayWithObjects: settingsButton, flexItem, systemItem, flexItem, systemItem1,flexItem, systemItem2, flexItem, systemItem3, flexItem, infoItem, nil];

     [toolbar setItems:toolbarItems];

    [settingsButton release];
    [systemItem  release];
    [systemItem1 release];
    [systemItem2 release];
    [systemItem3 release];
    [infoItem release];
    [flexItem release];

[super viewDidLoad];  

}


- (void) Infobuttonpressed: (id) sender
{
Infoviewcontroller *myView = [[Infoviewcontroller alloc] init];
[self presentModalViewController:myView animated:YES]; // present view modally
[self.navigationController pushViewController:myView animated:YES]; // add to navigation stack
[myView release];
}

In the Infoviewcontroller.h file have following code:

#import <UIKit/UIKit.h>

@interface Infoviewcontroller : UIViewController <UITextViewDelegate>

{

UITextView *textView;

}

@property (nonatomic, retain) UITextView *textView;
@property (nonatomic, assign) UINavigationBar *navBar;


@end

Then in the infoviewcontroller.m file have the following code:

#import "Infoviewcontroller.h"

@implementation Infoviewcontroller

@synthesize textView;
@synthesize navBar;



-(void)dealloc
{
[textView release];
    [navBar release];
[super dealloc];
}

 -(void)setupTextView
  {
self.textView = [[[UITextView alloc] initWithFrame:self.view.frame] autorelease];

self.textView.textColor = [UIColor redColor];

self.textView.font = [UIFont fontWithName:@"System Bold" size:13];

self.textView.delegate = self;

self.textView.backgroundColor = [UIColor whiteColor];

self.textView.textAlignment =  UITextAlignmentCenter;

self.textView.text = @"This is UITextView\nThis is UITextView\nThis is UITextView\nThis is UITextView"; 

[self.view addSubview: self.textView];    

}

- (void)viewDidLoad
{
[super viewDidLoad];

navBar = [[UINavigationBar alloc] init];
UINavigationItem *navItem = [[[UINavigationItem alloc] initWithTitle:@"ModalViewControllerTest"] autorelease];
UIBarButtonItem *done = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissView:)] autorelease];
navItem.rightBarButtonItem = done;
navBar.items = [NSArray arrayWithObject:navItem];
[self.view addSubview:navBar];
}
  • 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-28T00:34:44+00:00Added an answer on May 28, 2026 at 12:34 am
    UIBarButtonItem *infoItem = [[UIBarButtonItem alloc] 
                              initWithTitle:@"Info" 
                              style:UIBarButtonItemStyleBordered 
                              target:nil 
                              action:@selector(Infobuttonpressed)]; 
    

    Should be

    UIBarButtonItem *infoItem = [[UIBarButtonItem alloc] 
                              initWithTitle:@"Info" 
                              style:UIBarButtonItemStyleBordered 
                              target:self
                              action:@selector(Infobuttonpressed:)]; 
    

    Spot the difference? First, you’re missing a target (should be self, not nil). Second, the colon at the end of the selector is part of the signature, you were missing it so it was not calling your method (which is InfoButtonPressed:(id)sender).

    As an aside, methods should start with a lower case name.

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

Sidebar

Related Questions

I want to create an application which main window has canvas (or something where
I want to change the background color of our apps main window when a
I want to split the main window in three way Grid Spliiter same alike
Issue1: I want to show an alert window or message box before the Main
I have found several similar questions, but nothing that fits perfectly. I want my
I want to re-show the main window after closed when click my app icon
i want move two or more sticky windows when i move a main window
I have a few widgets in a main window. i want the user to
I created a window and want to intercept the exit with the method windowStateChanged
I have a main Window.Then if you touch settings button a new modal Window

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.