modalview help

Discussion in 'iOS Programming' started by uaecasher, Apr 19, 2010.

  1. uaecasher macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK
    #1
    Hello,

    I've created a button when pressed will show a modal view but the problem now I don't know to to add a button in that view that will remove it and go back to the main view.

    Code:
    
    UIView *modalView = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    	modalView.opaque = NO;
    	modalView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5f];
    	[self.view addSubview:modalView];
    
    
    any help? thank you.
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    If you already know how to add a button to perform an action, just do the same thing in the new view.

    Plus, technically, what you've done with the code above is not a modal view but just a subview. Modal views are presented and dismissed using UIViewController's presentModalViewController:animated: and dismissModalViewControllerAnimated: instance methods.
     
  3. uaecasher thread starter macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK
    #3
    okay, I learned how to add action in UIButton, but not sure how to go back to the main view.
     

Share This Page