Return to Snippet

Revision: 27751
at June 22, 2010 13:35 by B0nis


Initial Code
//declare the protocol 
@protocol ModalViewControllerDelegate<NSObject>
- (void) didFinishModalView: (ModalViewController*) aModalViewController;
@end

//declare a delegate property
@interface ModalViewController : UIViewController {
}

@property (nonatomic, assign) id<ModalViewControllerDelegate> delegate;

@end

//
[delegate didFinishModalView: self];

////////////////////

//make the view controller confort to the protocol
<ModalViewControllerDelegate>

//initiate modal view and present it
	ModalViewController *myModalViewController = [[MyViewController alloc] initWithNibName: @"ModalViewController" bundle: [NSBundle mainBundle]];
	
	myModalViewController.delegate = self;
	[self presentModalViewController: myModalViewController animated: YES];

//dismiss the modal view
- (void) didFinishModalView: (ModalViewControllerDelegate*) aModalViewControllerDelegate {
    [self dismissModalViewControllerAnimated: YES];
}

Initial URL

                                

Initial Description

                                

Initial Title
present / dissmiss modal view

Initial Tags

                                

Initial Language
iPhone