Posted By

streamt on 03/05/11


Tagged

c dialog modal objective


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

Tintenklecks
cnathan


Show Modal Dialog


 / Published in: Objective C
 

  1. -(IBAction)buttonClick:(id)sender
  2. {
  3.  
  4. PurchaseWindowViewController* viewController = [[PurchaseWindowViewController alloc] initWithNibName:@"PurchaseWindowViewController" bundle:nil];
  5.  
  6. UINavigationController *navController = [[UINavigationController alloc]
  7. initWithRootViewController:viewController];
  8.  
  9.  
  10. navController.modalPresentationStyle = UIModalPresentationFormSheet;
  11. navController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
  12.  
  13. viewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Cancel", @"") style:UIBarButtonItemStyleBordered target:self action:@selector(close)];
  14.  
  15. [self presentModalViewController:navController animated:YES];
  16.  
  17. //targetController.view.superview.frame = CGRectMake(0, 0, 200, 200);//it's important to do this after presentModalViewController
  18. //targetController.view.superview.center = self.view.center;
  19.  
  20. // Clean up resources
  21. [navController release];
  22. [viewController release];
  23.  
  24. }
  25.  
  26.  
  27. - (void)close
  28. {
  29. [self dismissModalViewControllerAnimated:YES];
  30. }

Report this snippet  

You need to login to post a comment.