All,

I have a DetailViewController that has its class set to UIControl and there is a "backgroundTouched" IBAction method that handles those background touch events perfectly. When I change the DetailViewController to be presented modally, in a FormSheet, I lose the ability to detect background touches so the keyboard will not dismiss on background touch. I think the cause is that previously, the DetailView was taking up the entire screen so all of the delegate methods fired but now that it's being presented modally, these delegate and IBAction methods are no longer able to communicate.

Am I correct in my analysis of the problem and how do I get the modal presentation to report events?

Thanks

   //Give it a nav controller
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:detailViewController];



/****************************************************
 *
 *  Use a modal form presentation for  form
 *  
 *
 ****************************************************/

    //Use a form sheet style for DetailView
    [navController setModalPresentationStyle:UIModalPresentationFormSheet];

    //flip-horizontal transition
    [navController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];



[self presentViewController:navController animated:YES completion:nil];


 }  
有帮助吗?

解决方案

It may be related to how Apple has chosen to handle keyboard dismissing during a modal presentation (i.e. basically don't hide it when it normally would hide. Rationale is that in a modal context it would likely go up and down too often). see Modal Dialog Does Not Dismiss Keyboard The accepted answer on that question has a good explanation, and my answer provides a good generic solution when using Navigation Controllers.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top