Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 1.94 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. dismissing modalview is not working
  2. - (void)displayModalViewaction: (id) sender
  3.  {
  4. self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  5.  
  6. self.viewController = [[Infoviewcontroller alloc] init];
  7.  
  8. [self.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
  9.  
  10.  
  11. UINavigationController *navigationController=[[UINavigationController alloc] init];
  12.  
  13. navigationController.navigationBar.tintColor = [UIColor brownColor];
  14.  
  15. [navigationController pushViewController:_viewController animated:YES];
  16.  
  17. [self.view addSubview:navigationController.view];
  18.  
  19. [_viewController release];
  20.  
  21. [navigationController release];
  22.  
  23. }
  24.        
  25. @protocol ModalViewDelegate <NSObject>
  26.  
  27.  -(void) dismissModalView:(UIViewController *) viewController;
  28.  
  29.  @end
  30.  
  31.  @interface Infoviewcontroller : UIViewController <ModalViewDelegate>
  32.  
  33.  {
  34.     id<ModalViewDelegate> dismissDelegate;
  35.   }
  36.  
  37. @property (nonatomic, retain) id<ModalViewDelegate> dismissDelegate;
  38.  
  39. @end
  40.        
  41. @synthesize dismissDelegate;
  42.  
  43. -(void) dismissModalView:(UIViewController *) viewController;
  44. {
  45.  
  46.    [self dismissModalViewControllerAnimated:YES];
  47.  
  48.  }
  49.   @end
  50.  
  51.    -(void) dismissView: (id)sender
  52.  
  53.   {
  54.     [delegate dismissModalView:self];
  55.  
  56.  }
  57.  
  58.  -(void) dismissModalView:(UIViewController *) viewController;
  59. {
  60.  
  61.  [self.dismissModalViewController Animated:YES];
  62.  
  63. }
  64.  
  65. @end
  66.        
  67. UIButton* backButton = [UIButton buttonWithType:101];
  68.   [backButton addTarget:self action:@selector(dismissView:)   forControlEvents:UIControlEventTouchUpInside];
  69.   [backButton setTitle:@"Done" forState:UIControlStateNormal];
  70.  
  71. // create button item
  72. UIBarButtonItem* backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
  73.  
  74. // add the button to navigation bar
  75. self.navigationItem.leftBarButtonItem = backItem;
  76. [backItem release];
  77.        
  78. [navigationController presentModalViewController:_viewController animated:YES];
  79.        
  80. [self.navigationController popViewControllerAnimated:YES];
  81.        
  82. [self dismissModalViewControllerAnimated:YES];