
Untitled
By: a guest on
May 16th, 2012 | syntax:
None | size: 1.29 KB | hits: 13 | expires: Never
Trigger events when switching views
secondView *secondViewController;
secondViewController = [[SecondView alloc]
initWithNibName:@"SecondView" bundle:nil];
[self.view addSubview:SecondViewController.view];
[self.view removeFromSuperView];
[self.navigationController pushViewController:secondViewController animated:YES];
- (void) backButtonClicked:(id)sender {
[self.view removeFromSuperView];
[[NSNotificationCenter defaultCenter] postNotificationName:@"back"
object:self.view];
}
- (void) pushSecondViewController {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(secondViewDidGoBack:)
name:@"back"
object:secondViewController.view];
SecondView *secondViewController = [[SecondView alloc] initWithNibName:@"SecondView"
bundle:nil];
[self.view addSubview:secondViewController.view];
}
- (void) secondViewDidGoBack:(NSNotification *)notification {
[[NSNotificationCenter defaultCenter] removeObserver:self];
NSLog(@"My Second View Did Go back !");
}