Created
October 10, 2012 05:55
-
-
Save ChrisRisner/3863413 to your computer and use it in GitHub Desktop.
iOS Day 6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@class SecondViewController; | |
@protocol SecondViewControllerDelegate <NSObject> | |
- (void)doSomethingWithSecondViewController:(SecondViewController *)secondViewController; | |
@end | |
@interface SecondViewController : UIViewController | |
@property (nonatomic, weak) id <SecondViewControllerDelegate> delegate; | |
- (IBAction)tappedCloseModal:(id)sender; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation SecondViewController | |
@synthesize delegate; | |
- (IBAction)tappedCloseModal:(id)sender { | |
[delegate doSomethingWithSecondViewController:self]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (IBAction)tappedShowNewView:(id)sender { | |
SecondViewController *secondViewController = | |
[self.storyboard instantiateViewControllerWithIdentifier:@"secondViewController"]; | |
secondViewController.delegate = self; | |
[self presentModalViewController:secondViewController animated:YES]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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