Modal View won't dissapear after dismissed

Discussion in 'iOS Programming' started by l0uismustdie, Dec 23, 2010.

  1. l0uismustdie macrumors regular

    l0uismustdie

    Joined:
    Nov 30, 2009
    Location:
    Edinburgh, UK
    #1
    Hello. The app I am working on consists of a few views that I present and dismiss from my appDelegate. I am using the same strategy to present and dismiss all the view:
    -create an object for the viewController
    -present the view
    -call a function in the appDelegate to dismiss the view when I'm finished

    However, I've just implemented a table view and this doesn't seem to be working the same. This is how it is presented and dismissed:
    Code:
    -(void)showProjects
    {
    	ProjectIndex	*pController=[[[ProjectIndex alloc]init]autorelease];
    	[viewController presentModalViewController:pController animated:NO];	
    }
    -(void)dismissProjects
    {
    	[viewController dismissModalViewControllerAnimated:YES];
    }
    
    This is identical to how I have been accomplishing this previously. I know for a fact I am getting to the dismiss line but it doesn't seem to dismiss that view. Is there something different about table views?

    Thanks!
     
  2. l0uismustdie thread starter macrumors regular

    l0uismustdie

    Joined:
    Nov 30, 2009
    Location:
    Edinburgh, UK
    #2
    So I have solved this problem but I am not sure why. What I did was change
    Code:
    vmAppDelegate *appDelegate=[[[vmAppDelegate alloc]init]autorelease];
    [appDelegate dismissProjects];
    
    to
    Code:
    vmAppDelegate *appDelegate=[[UIApplication sharedApplication]delegate];
    [appDelegate dismissProjects];
    
    But the truth is I am not sure why this works or what the difference really is between this two declarations.
     
  3. cnstoll macrumors 6502

    Joined:
    Aug 29, 2010
    #3
    It seems like allocating a new instance of an app delegate would never work. I believe your second try works because that's passing the pointer to "your" app delegate..which is what you actually want.
     

Share This Page