Need to dismiss the modalview form sheet controller when tap occurs on outside of the view?

Ah ok. So I'm afraid thats not quite possible using the presentModalViewController: method. The whole idea of a "modal" view/window/message box/etc. pp.

Is that the user cannot do anything else than processing whatever the view/window/message box/etc. pp. Wants him/her to do.

Up vote 1 down vote favorite share g+ share fb share tw.

I have a question. I am presenting a modalview controller as a form sheet and dismissing it when the cancel button which is a bar button item is clicked. My question is I need to dismiss it when I tap on outside of that view.

Please help me with some some reference. Note: my modal view controller is presented with navigation controller. @cli_hlt, @Bill Brasky thanks for your answer.

I need to dismiss it when tap occurs outside of the modal view which is a form sheet. I am pasting my code below. -(void)gridView:(AQGridView *)gridView didSelectItemAtIndex:(NSUInteger)index { if (adminMode) { CHEditEmployeeViewController *editVC = CHEditEmployeeViewController alloc initWithNibName:@"CHEditEmployeeViewController" bundle:nil; editVC.

Delegate = self; editVC. PickedEmployee = employee; editVC. Edit = TRUE; editVC.

Delegate = self; UINavigationController *navigationController = UINavigationController allocinitWithRootViewController:editVC; navigationController. ModalPresentationStyle = UIModalPresentationFormSheet; self presentModalViewController:navigationController animated:YES; return; } //the above code is from the view controller which presents the modal view. Please look at the below code too which is from my modal view controller.

Please guide me in a proper way. -(void)tapGestureRecognizer { UITapGestureRecognizer *recognizer = UITapGestureRecognizer alloc initWithTarget:self action:@selector(handleTapBehind:); recognizer setNumberOfTapsRequired:1; recognizer. CancelsTouchesInView = NO; //So the user can still interact with controls in the modal view self.

View addGestureRecognizer:recognizer; } - (void)handleTapBehind:(UITapGestureRecognizer *)sender { if (sender. State == UIGestureRecognizerStateEnded) { CGPoint location = sender locationInView:nil; //Passing nil gives us coordinates in the window //Then we convert the tap's location into the local view's coordinate system, and test to see if it's in or outside. If outside, dismiss the view.

If (!self. View pointInside:self. View convertPoint:location fromView:self.view.

Window withEvent:nil) { self dismissModalViewControllerAnimated:YES; self.view. Window removeGestureRecognizer:sender; } } } objective-c xcode uinavigationcontroller modalviewcontroller link|improve this question edited Feb 1 at 21:20 asked Feb 1 at 20:07jessy276 85% accept rate.

Ah ok. So I'm afraid thats not quite possible using the presentModalViewController: method. The whole idea of a "modal" view/window/message box/etc. pp.

Is that the user cannot do anything else than processing whatever the view/window/message box/etc. pp. Wants him/her to do. What you want to do instead is not present a modal view controller, but rather load and show your form view controller the regular way.

Note in your master controller that the form is just showing e.g. With a BOOL variable and then handle there any taps that might occur. If your form is showing, dismiss it.

This will also dismiss the modal if you tap on anything inside the modal view as well that isn't wired up. (blank space, etc.) – Bill Burgess Feb 1 at 20:20 I thought his/her intent was to dismiss the modal when tapping outside of the form elements - not just the cancel button? – cli_hlt Feb 1 at 20:26 Possibly.

Just thought it was worth mentioning in case that doesn't give the expected results. The question seemed like they wanted it to dismiss when tapping outside the form sheet view, so wanted to make things clear. – Bill Burgess Feb 1 at 20:30 Noted that, edited my answer accordingly.

– cli_hlt Feb 1 at 20:34 I have edited my question, Please have a look at them.Thanks. – jessy Feb 1 at 21:21.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions