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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:38:15+00:00 2026-05-28T06:38:15+00:00

i m presenting modalviewcontroller without using delegate protocol. But want to dismiss modalviewcontroller using

  • 0

i m presenting modalviewcontroller without using delegate protocol. But want to dismiss modalviewcontroller using delegate protocol.

Basically i m pushing modalviewcontroller like this

- (void)displayModalViewaction: (id) sender 
 {
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

self.viewController = [[Infoviewcontroller alloc] init];

[self.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];


UINavigationController *navigationController=[[UINavigationController alloc] init];

navigationController.navigationBar.tintColor = [UIColor brownColor]; 

[navigationController pushViewController:_viewController animated:YES];

[self.view addSubview:navigationController.view];

[_viewController release];

[navigationController release];

}

For dismissing modalview doing this

In the ModalViewController.h delegated protocol and method

 @protocol ModalViewDelegate <NSObject>

 -(void) dismissModalView:(UIViewController *) viewController;

 @end

 @interface Infoviewcontroller : UIViewController <ModalViewDelegate>

 {
    id<ModalViewDelegate> dismissDelegate;
  }

@property (nonatomic, retain) id<ModalViewDelegate> dismissDelegate;

@end

In modalviewcontroller. m file

@synthesize dismissDelegate;

-(void) dismissModalView:(UIViewController *) viewController;
{

   [self dismissModalViewControllerAnimated:YES];

 }
  @end

   -(void) dismissView: (id)sender

  {
    [delegate dismissModalView:self];

 }

 -(void) dismissModalView:(UIViewController *) viewController;
{

 [self.dismissModalViewController Animated:YES];

}

@end

But somehow it is not working when clicking on done button

 UIButton* backButton = [UIButton buttonWithType:101]; 
  [backButton addTarget:self action:@selector(dismissView:)   forControlEvents:UIControlEventTouchUpInside];
  [backButton setTitle:@"Done" forState:UIControlStateNormal];

// create button item
UIBarButtonItem* backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];

// add the button to navigation bar
self.navigationItem.leftBarButtonItem = backItem;
[backItem release];

Anyone have any clue that what i m missing in my code or what i m doing wrong. Help will be really appreciated.

Thanks

  • 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-28T06:38:16+00:00Added an answer on May 28, 2026 at 6:38 am

    I would have liked to comment, but not enough privilege. Anyways AFAIK…

    One does not ‘push’ a modal VC… it needs to be ‘presented’ like this..

    [navigationController presentModalViewController:_viewController animated:YES];
    

    Only a presented Modal VC will get dismissed on calling [self dismissModalViewControllerAnimated:YES];

    OR, in case you really need to ‘push’ it.. then you need to ‘pop’ it to get back!

    Hope it helps

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

Sidebar

Related Questions

I'm presenting a modalViewController. After I dismiss the modal view controller with: - (void)dismissModalViewControllerAnimated:(BOOL)animated
In my application mainviewcontroller is pushing modalviewcontroller by using this [navigationController pushViewController:_viewController animated:YES]; For
I'm using a pretty standard recipe for presenting ModalViewControllers in my iPhone apps, but
I'm not sure why this is happening, but in the App delegate, I'm setting
I am presenting a modal view controller like this from a table view (ignore
I am presenting a TTWebController as a Modal View using this code: TTNavigator* navigator
In my application, I'm presenting a modalViewController with a navigationbar on the top of
When presenting my UIImagePickerController with editing enabled, what does this bounding box mean during
I'm presenting a VC modally, then I dismiss it when a cell is selected
I'm presenting a simple animation using img.src replace and the <canvas> tag. At present

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.