Posted By

B0nis on 06/22/10


Tagged

protocol Delegate


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

bobbym245


present / dissmiss modal view


 / Published in: iPhone
 

  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  

You need to login to post a comment.