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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:08:36+00:00 2026-05-26T09:08:36+00:00

I’ve been trying to debug this issue for hours upon hours but with no

  • 0

I’ve been trying to debug this issue for hours upon hours but with no luck. I have a button that when pressed simply does this:

[self.parentViewController dismissModalViewControllerAnimated:NO];

Now I have a lot of AVAudioPlayers and AVAudioRecorders going on, but I’m sure to handle all that carefully before exiting. The weird thing is that pressing this button doesn’t always cause the app to crash. Only after a certain amount of time has passed, the app crashes upon clicking. So if I press the button 2 seconds after the page loads, then I am able to dismiss the view with no problems, and it goes back to other view. However if I wait 9 or more seconds, I get a crash.

I know it’s impossible to help me with this little info, but how do I begin debugging this issue? I don’t get any useful output when it crashes, just BAD_ACCES and no message at all. How can I look deeper into this and find what’s going on? The debugger isn’t helping either.

EDIT: I’m not sure if I’ve fixed the issue since it’s random, but when I first create the view controller that I will later dismiss, I do this:

CloseDoorViewController *closeVC=[[CloseDoorViewController alloc] init];
[self.view addSubview:closeVC.view];
[self presentModalViewController:closeVC animated:NO];
[closeVC release];

Then when I’m in CloseDorView, and I hit dismissModalViewController, I get a crash. But after commenting out [closeVC release];, the issue goes away (I think). So am I not supposed to be releasing closeVC? What is the proper way to do this?

  • 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-26T09:08:37+00:00Added an answer on May 26, 2026 at 9:08 am

    What I suspect is happening here is that you’re trying to dismiss the modal view controller from within a button click handler in the actual modal view controller’s code. Here is what I always do when displaying a modal view controller:

    In this example, vc1 is the “parent” (I use that loosely) view controller that will present vc2.

    (1). create a protocol (“ModalViewControllerDelegate.h”):

    
    //ModalViewControllerDelegate.h
    @protocol ModalViewControllerDelegate 
    -(void)viewControllerDidFinishShowing:(UIViewController*)controller;
    @end
    

    (2). edit vc1 like so:

    
    //vc1.h:
    #import "ModalViewControllerDelegate.h"
    //...
    @interface vc1 : UIViewController 
    <ModalViewControllerDelegate>
    {
    //...
    }
    
    
    //vc1.m
    #import "vc2.h"
    //...
    #pragma mark -
    #pragma mark ModalViewControllerDelegate Methods
    -(void)viewControllerDidFinishShowing:(UIViewController *)controller
    {
        if(self.modalViewController == controller)
        {
            [self dismissModalViewControllerAnimated:YES];
        }
    }
    //...
    

    (3). edit vc2 like so:

    
    //vc2.h
    #import "ModalViewControllerDelegate.h"
    //...
    @interface vc2 : UIViewController 
    {
      id modalDelegate;
    //...
    }
    //...
    @property (nonatomic, assign) id modalDelegate;
    - (IBAction)dismissButtonClicked:(id)sender;
    
    
    //vc2.m
    - (void)dealloc
    {
    //...
        self.delegate = nil;
    //...
    }
    //...
    - (IBAction)dismissButtonClicked:(id)sender
    {
      if(self.modalDelegate)
       {
           if([self.modalDelegate respondsToSelector:@selector(viewControllerDidFinishShowing:)])
           {
               [self.modalDelegate viewControllerDidFinishShowing:self];
           }
       }
    }
    

    (4). present vc2 from vc1 like so:

    
    //vc1.m
    //...
    vc2 *controller = [[vc2 alloc] initWithNibName:@"vc2" bundle:[NSBundle mainBundle]];
    controller.modalDelegate = self;//very important
    [self presentModalViewController:controller animated:YES];
    [controller release];
    //...
    

    Explanation:
    vc1 creates vc2 and sets itself as the delegate for vc2… when the dismiss button is clicked in the view of vc2, it checks for the existence of a delegate, finds vc1, and the appropriate selector/method in vc1 fires…which dismisses vc2.

    I hope that helps.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.