Created
May 15, 2012 07:11
-
-
Save tonyarnold/2699700 to your computer and use it in GitHub Desktop.
How do i call a parent ViewController's method?
This file contains 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 "ViewController.h" | |
@interface Peekaboo : UIView | |
@property (nonatomic, retain) ViewController *parentView; | |
- (void) show; | |
@end |
This file contains 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 "Menu.h" | |
@implementation Menu | |
@synthesize parentView; | |
- (id)initWithFrame:(CGRect)frame | |
{ | |
self = [super initWithFrame:frame]; | |
if (self) { | |
//do the bullshit here | |
} | |
return self; | |
} | |
- (void) show { | |
//this tells me that the parent view doesnt have a selector called showMyLabel | |
[parentView showMyLabel]; | |
} |
This file contains 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 "Peekaboo.h" | |
@interface ViewController : UIViewController | |
- (void) showMyLabel; | |
//views | |
@property (nonatomic, retain) Peekaboo *peekabooView; | |
@end |
This file contains 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 "ViewController.h" | |
@interface ViewController () | |
@end | |
@implementation ViewController | |
@synthesize peekabooView; | |
//view controller initiation | |
- (void)viewDidLoad { | |
//peekaboo view | |
peekabooView = [[Menu alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)]; | |
peekabooView.parentView = self; | |
[self.view insertSubview:peekabooView atIndex:1]; | |
//create the label and hide it and stuff | |
} | |
- (void) showMyLabel { | |
//show the stupid label created above | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment