Skip to content

Instantly share code, notes, and snippets.

@ChrisRisner
Created October 10, 2012 05:55
Show Gist options
  • Save ChrisRisner/3863413 to your computer and use it in GitHub Desktop.
Save ChrisRisner/3863413 to your computer and use it in GitHub Desktop.
iOS Day 6
@class SecondViewController;
@protocol SecondViewControllerDelegate <NSObject>
- (void)doSomethingWithSecondViewController:(SecondViewController *)secondViewController;
@end
@interface SecondViewController : UIViewController
@property (nonatomic, weak) id <SecondViewControllerDelegate> delegate;
- (IBAction)tappedCloseModal:(id)sender;
@end
@implementation SecondViewController
@synthesize delegate;
- (IBAction)tappedCloseModal:(id)sender {
[delegate doSomethingWithSecondViewController:self];
}
#import <UIKit/UIKit.h>
#import "SecondViewController.h"
@interface ViewController : UIViewController <SecondViewControllerDelegate>
@property (weak, nonatomic) IBOutlet UILabel *lblInfo;
@property (weak, nonatomic) IBOutlet UITextField *txtText;
- (IBAction)tappedClickMe:(id)sender;
- (IBAction)tappedNavButton:(id)sender;
- (IBAction)tappedShowNewView:(id)sender;
@end
- (IBAction)tappedShowNewView:(id)sender {
SecondViewController *secondViewController =
[self.storyboard instantiateViewControllerWithIdentifier:@"secondViewController"];
secondViewController.delegate = self;
[self presentModalViewController:secondViewController animated:YES];
}
- (void)doSomethingWithSecondViewController:(SecondViewController *)secondViewController {
[self dismissModalViewControllerAnimated:YES];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment