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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:16:56+00:00 2026-05-20T02:16:56+00:00

I have a confusion on canceling the modal views: Case 1: I have a

  • 0

I have a confusion on canceling the modal views:

Case 1: I have a navigation view controller and I am presenting a modal view controller from this navigation view controller. Now, when I am to cancel this modal view from where should I call the dismissModalView method — navigation view controller or the modal view controller?

Case 2: I have a modal view controller and I am presenting another modal view controller from first modal view controller. Now, when I am to cancel second modal view from where should I call the dismissModalView method — frist modal view controller or the second modal view controller?

Will canceling it from a wrong place cause a app crash also?

  • 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-20T02:16:57+00:00Added an answer on May 20, 2026 at 2:16 am

    An advisable way to handle modal view controllers is to us notifications to inform the class that presented it to release it. Generally, you use code similar to this to show a modal view.

    SomeClass *yourViewController = [[SomeClass alloc] initWithNibName:@"SomeClass" bundle:nil];
    [self presentModalViewController: yourViewController animated: YES];
    [yourViewController release];
    

    With the above code, your modal view should end up with a retain count of 1. When you dismiss it, the parent view will release it and it will be purged from memory. Your “close” button in your modal view should execute code that looks like this:

    - (void)dismissSelf{
      [[NSNotificationCenter defaultCenter] postNotifivationName:@"I'm done" object:self];
    }
    

    Back in your parent viewcontroller, ou should listen for this notification and then dismiss the modal view when the notification is posted.

    That said, to answer your questions:

    1. A modal view controller never dismisses itself. Post a notification and then let the navigation controller handle it.

    2. You can’t dismiss the first modal view until the second one has been dismissed. If you do, you will get a EXC_BAD_ACCESS error. Think of the second modal view as “inside” the first one. If the first is dismissed, the second one will be dragged away with it, but it hasn’t been dismissed.

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

Sidebar

Related Questions

I have some confusion with this that arose from messing around with exporting generic
I have confusion over the responsibilities of a View and View-controller. I have read
Based on an answer from a candidate I have a confusion regarding the functioning
I am learning Hibernate from the tutorials on JBoss website. I have a confusion
I have this confusion and perhaps it may be basic question. I am planning
I have some confusion regarding how the frame size bytes should be coded/decoded for
This is probably a very simple question but I have a confusion about the
hi i have a confusion about xml please tell me is this valid xml
I have some confusion regarding When should we use disributed architecture. I know concept
I have bit confusion about parameters. When we should have to use reference parameter

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.