Advertisement
RRK

Custom UIActionSheet

RRK
Dec 12th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. I am trying to implement a custom UIActionSheet(made up of a ViewController)
  2. I have added a View Controller as a subView to the navigationcontroller of my rootView
  3.  
  4. - (IBAction)ShowMenu:(id)sender
  5. {
  6.    [self.navigationController.view addSubview:self.menuViewController.view];
  7.    [self.menuViewController setTest:YES];
  8.    [self.menuViewController viewWillAppear:YES];
  9. }
  10.  
  11. here MenuViewController has a tableview which has few options to select. After selecting I am opening those respective ViewControllers. Suppose I clicked on menu1 and then opened menu1ViewController and it works fine. Now when I close this viewController, I am calling dismissViewController.
  12.  
  13. and in menuViewController I have written the code to animate by menuviewController to bottom and it works fine.
  14.  
  15. but the parent of MenuView is TestViewController inside which the functions viewdidAppear is not called when menuviewController animates down.
  16.  
  17. and thats my problem,
  18.  
  19. I am using this code to animate by menuViewController to bottom
  20.  
  21. - (void) slideOut {
  22.  
  23.    
  24.   [UIView beginAnimations:@"removeFromSuperviewWithAnimation" context:nil];
  25.    
  26.     // Set delegate and selector to remove from superview when animation completes
  27.     [UIView setAnimationDelegate:self];
  28.     [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
  29.    
  30.     // Move this view to bottom of superview
  31.     CGRect frame = self.menusheet.frame;
  32.     frame.origin = CGPointMake(0.0, self.view.bounds.size.height);
  33.     self.menusheet.frame = frame;
  34.  
  35.     [UIView commitAnimations];
  36. }
  37.  
  38. // Method called when removeFromSuperviewWithAnimation's animation completes
  39. - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
  40.     if ([animationID isEqualToString:@"removeFromSuperviewWithAnimation"]) {
  41.         [self.view removeFromSuperview];
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement