present / dissmiss modal view


/ Published in: iPhone
Save to your folder(s)



Copy this code and paste it in your HTML
  1. //declare the protocol
  2. @protocol ModalViewControllerDelegate<NSObject>
  3. - (void) didFinishModalView: (ModalViewController*) aModalViewController;
  4. @end
  5.  
  6. //declare a delegate property
  7. @interface ModalViewController : UIViewController {
  8. }
  9.  
  10. @property (nonatomic, assign) id<ModalViewControllerDelegate> delegate;
  11.  
  12. @end
  13.  
  14. //
  15. [delegate didFinishModalView: self];
  16.  
  17. ////////////////////
  18.  
  19. //make the view controller confort to the protocol
  20. <ModalViewControllerDelegate>
  21.  
  22. //initiate modal view and present it
  23. ModalViewController *myModalViewController = [[MyViewController alloc] initWithNibName: @"ModalViewController" bundle: [NSBundle mainBundle]];
  24.  
  25. myModalViewController.delegate = self;
  26. [self presentModalViewController: myModalViewController animated: YES];
  27.  
  28. //dismiss the modal view
  29. - (void) didFinishModalView: (ModalViewControllerDelegate*) aModalViewControllerDelegate {
  30. [self dismissModalViewControllerAnimated: YES];
  31. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.