Guest User

Untitled

a guest
May 16th, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. Trigger events when switching views
  2. secondView *secondViewController;
  3. secondViewController = [[SecondView alloc]
  4. initWithNibName:@"SecondView" bundle:nil];
  5. [self.view addSubview:SecondViewController.view];
  6.  
  7. [self.view removeFromSuperView];
  8.  
  9. [self.navigationController pushViewController:secondViewController animated:YES];
  10.  
  11. - (void) backButtonClicked:(id)sender {
  12. [self.view removeFromSuperView];
  13. [[NSNotificationCenter defaultCenter] postNotificationName:@"back"
  14. object:self.view];
  15. }
  16.  
  17. - (void) pushSecondViewController {
  18. [[NSNotificationCenter defaultCenter] addObserver:self
  19. selector:@selector(secondViewDidGoBack:)
  20. name:@"back"
  21. object:secondViewController.view];
  22.  
  23. SecondView *secondViewController = [[SecondView alloc] initWithNibName:@"SecondView"
  24. bundle:nil];
  25. [self.view addSubview:secondViewController.view];
  26. }
  27.  
  28. - (void) secondViewDidGoBack:(NSNotification *)notification {
  29. [[NSNotificationCenter defaultCenter] removeObserver:self];
  30.  
  31. NSLog(@"My Second View Did Go back !");
  32. }
Advertisement
Add Comment
Please, Sign In to add comment