- dismissing modalview is not working
- - (void)displayModalViewaction: (id) sender
- {
- self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
- self.viewController = [[Infoviewcontroller alloc] init];
- [self.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
- UINavigationController *navigationController=[[UINavigationController alloc] init];
- navigationController.navigationBar.tintColor = [UIColor brownColor];
- [navigationController pushViewController:_viewController animated:YES];
- [self.view addSubview:navigationController.view];
- [_viewController release];
- [navigationController release];
- }
- @protocol ModalViewDelegate <NSObject>
- -(void) dismissModalView:(UIViewController *) viewController;
- @end
- @interface Infoviewcontroller : UIViewController <ModalViewDelegate>
- {
- id<ModalViewDelegate> dismissDelegate;
- }
- @property (nonatomic, retain) id<ModalViewDelegate> dismissDelegate;
- @end
- @synthesize dismissDelegate;
- -(void) dismissModalView:(UIViewController *) viewController;
- {
- [self dismissModalViewControllerAnimated:YES];
- }
- @end
- -(void) dismissView: (id)sender
- {
- [delegate dismissModalView:self];
- }
- -(void) dismissModalView:(UIViewController *) viewController;
- {
- [self.dismissModalViewController Animated:YES];
- }
- @end
- UIButton* backButton = [UIButton buttonWithType:101];
- [backButton addTarget:self action:@selector(dismissView:) forControlEvents:UIControlEventTouchUpInside];
- [backButton setTitle:@"Done" forState:UIControlStateNormal];
- // create button item
- UIBarButtonItem* backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
- // add the button to navigation bar
- self.navigationItem.leftBarButtonItem = backItem;
- [backItem release];
- [navigationController presentModalViewController:_viewController animated:YES];
- [self.navigationController popViewControllerAnimated:YES];
- [self dismissModalViewControllerAnimated:YES];