Persistent Popover with VoiceOver - ios

I have an iPad popover with a button that triggers a modal segue to a full-screen view controller. It works fine and the popover dismisses itself. But, when VoiceOver is on, the labels of the popover persist and this interferes with the user hearing the new screen's VoiceOver labels. Even though the popover is dismissed, I can see the outlines of its labels as they are selected in VoiceOver. What am I doing wrong?

Just to answer my own question, placing:
self.view.accessibilityViewIsModal = YES;
in my destination view controller's viewWillAppear: resolved the issue.

Related

Show/hide dismiss button in a UIPopoverPresentationController

I have a UINavigationController that I'm presenting in a popover using UIPopoverPresentationController.
The navigation controller must be presented when displayed in both popover and fullscreen mode (as the adaptive system so chooses.)
I have all this working.
The problem comes when I want to show/hide a dismiss button in the navigation controller depending on how it's being presented. I can't seem to determine whether I'm popover or fullscreen?
The WWDC stuff talks about returning a new navigation controller in presentationController:viewControllerForAdaptivePresentationStyle - but that's no good in my case as my navigation controller may have had other controllers pushed onto it and so cannot simply be swapped out.
Any pointers would be most welcome.
Thanks
[UPDATE] So the presenting view controller gets traitCollectionDidChange: and if it's horizontal compact then I poke into the presentedViewController->childViewControllers[0].navigationItem.leftBarButtonItem and set it to 'close'. But boy does this feel hacky.
[UPDATE2] So this link helps Close button on adaptive popover but the dismiss button is not then cleared when it switches back out to regular width.

Should I dismiss keyboard before dismissing the view?

I have two UIViewControllers, on modally presented over the other. The first controller is orientated in landscape, and the modal view is presented in portrait.
When dismissing the modal view, the view animates to reveal the landscape view below. If the keyboard is visible on the modal view at this time, it will suddenly attach itself to the left or right side of the screen to match the orientation of the soon-to-be active viewController.
Is there a way to let the keyboard disappear in the same orientation as the disappearing viewController? Or should I perhaps dismiss the keyboard before dismissing the modal view controller? In that case, what would be the best approach?
I do have an action for when the user clicks 'close'. I can there check if any objects are firstResponder, and start a timer for ~0.4 seconds before dismissing.. But it would obviously create a kind of delay that wouldn't feel all that natural.. I'd prefer a way to let the keyboard stay attached to the same orientation as the dismissing view.
This is happening:
I think the best practice would be to dismiss the keyboard before dismissing your modal ViewController. The keyboard is presented over your content and should be removed first before removing other items in the view hierarchy.

Prevent popovers from displaying over presented views

I am attempting to display a passcode screen that appears after X amount of inactivity. I use presentViewController:animated:completion: on the root view controller, and it works as expected, except when a popover is already being displayed. The popover, displayed from a bar button item, appears over the presented passcode screen.
Is there a way to dismiss or hide all visible popovers when presenting a view controller?
Create and add a 2nd window over the first. Present the passcode screen in the 2nd window. This will allow it to appear over any and all views from the first window. When you dismiss the passcode screen, be sure to remove the new window and make the 1st one key again.
Do you have a reference to the popover? Then you can just call
[popover dismissPopoverAnimated:NO];
when you go to shop the passcode overlay.
EDIT
Looping through subviews and seeing if you can dimiss a popover. I'd really recommend trying to find some other way of doing things as this is just icky. But it should work (untested).
for (UIView* view in self.view.subviews) {
if([view respondsToSelector:#selector(dismissPopoverAnimated:)]){
[(UIPopoverController*)view dismissPopoverAnimated:NO];
}
}
NSNotifications are a good tool for this problem. Have all your views or controllers that present popovers listen for a notification named, say, WillPresentPasscodeScreen, and implement a method that dismisses the popover when the notification comes in. Then, before you present your passcode VC, post a WillPresentPasscodeScreen notification -- no more popovers, regardless of where you are in the app.

Contents of UIPopover change to random orientation when Modal View is visible and iPad rotated

I have a UITableView within a navigation controller shown within a popover. When you press a bar button from within the popover (on a detail view), it shows a modal view. If you rotate the iPad with the popover visible and the modal view on top of that, the popover's content changes to a seemingly random orientation as shown below.
Any idea what's going on here?
UPDATE:
I'm trying to implement a solution, maybe there's a better way. When the modal view is dismissed, I send an NSNotification from - (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error to the popover's owner.
When I press cancel, the button is visibly pressed but nothing happens after that and the screen becomes unresponsive. However, rotation still occurs properly.
It would seem that I'm dismissing the popover before the modal view is dismissed. I don't really know any other way of doing this, you're continued help is appreciated.
I had to completely reload the popover and its view controllers. This is the only way I could mask the problem, not solve it, because this seems to be a bug in iOS 3.2.
Have you tried to dismiss the popover and then redisplay it? The UIPopoverController documentation is straightforward in saying that it will often fail to rotate a popover, and suggests redisplaying it as the only solution. I suspect that since your modal view is on top of the view from which the popover was displayed, the popover's controller is not updating its position & orientation.

UIPopover locking background view

I am trying to replicate the iPad passcode view. Which basically is a popover with no arrow direction, that locks the background view kinda like a modal view controller.
My question: Is there a way to lock the underlying background view when presenting a popover.
My idea: The only real solution that i could come up with is placing that popover inside a modal view controller. and presenting it that way.
Thoughts?
Use the modalInPopover property of your view controller: http://developer.apple.com/iphone/library/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926-CH3-SW72
This question provides some information on making a popover with no arrows, though it's not clear whether it's correct or not: UIPopover without any arrows

Resources