Is it possible to prevent the default nature of the iPad not iPhone UIAlertView so that when a person clicks outside the bounds of the UIAlertView it will not dismiss? Currently you can click anywhere on the screen and it will just dismiss but I can not have this feature because the user has to click something inside the alert view otherwise my application will not run right and it will crash!
So is there any way to change this default behavior?
Thanks!
What you can do is to show a view that blocks the screen and then call the UIAlertView.
So now you have your view, the blocking view and the UIAlertView in front.
When you clic the UIAlertView option you also dismiss the blockingView.
This blocking View is like a loading View but without a spinner.
Related
On an iPad, you can use controller.modalPresentationStyle = UIModalPresentationFormSheet to show a centered modal on the screen. A common technique is to allow the user to dismiss the modal by clicking "outside" or "behind" it. This is covered in numerous other answers (Iphone SDK dismissing Modal ViewControllers on ipad by clicking outside of it,
Dismiss modal view form sheet controller on outside tap), usually by adding a tap gesture to the view's UIWindow.
My question is, how do I make this accessible to users in VoiceOver mode? The native action sheets allow clicks outside the sheet to dismiss, and even prompt the user, saying "double tap to dismiss popup window". How can I expose the UIWindow tap gesture in the same way?
From Apple:
https://support.apple.com/guide/iphone/learn-voiceover-gestures-iph3e2e2281/ios
Dismiss an alert or return to the previous screen: Two-finger scrub
(move two fingers back and forth three times quickly, making a āzā).
If the modal sheet is opened, we can prompt the user to "make a z gesture" to go back.
There is basically no way to do this with the FormSheet presentation. You can use the Popover presentation, but it behaves differently in some cases.
My solution was to check UIAccessibilityIsVoiceOverRunning() and add an extra close button element to the top of FormSheet that can be clicked via voiceover. I also implemented accessibilityPerformEscape for the global escape gesture.
I wanted to display a Popup view on top of the screen but while enabling the actual screen as well. User should be able to perform all touch actions on the screen's controller while displaying and allowing touch actions on popup view as well. No fade for background ofcourse.
I do not see a existing style for UIAlertController that meets this need.
Is it possible with UIAlertController?
(PS. with UIPopoverPresentationController Custom style, managed to disable fade but still couldn't get the touch controls work on background screen)
Sounds like you might want to look into passthroughViews property on UIPopoverPresentationController. From the documentation:
"When displayed, taps outside of the popover window cause the popover to be dismissed automatically. To allow the user to interact with the specified views and not dismiss the popover, you can assign one or more views to the passthroughViews property."
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIPopoverController_class/
I want to know how the UIAlertController work. I am trying to develop loading a view which will do the same like UIActivityIndicatorView. When my loading view is appearing on the screen, I want to do the same thing like UIAlertController which code made the whole screen black and user interaction disabled to that view until the user click "OK". Any help please?
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.
I am using UIAlertView to let the user know some information, I have a button on the AlertView that when clicked triggers a whole new view to be shown.
The pseudo code run when the button is clicked is:
Find my UIViewController, and initiate the veiw controller for my new view, and call presentModalViewController:mySecondView animated:Yes
And this works fine..
On mySecondView I have a button that I use to dismiss the view using dismissModalViewControllerAnimated:YES
Now, the transitions work, I click on the UIAlertView Button and the SecondView appears, and when I click on the Exit Button my original View appears, unfortunately it appears without the ALERTVIEW that started the transition..
I want the first view to reappear with the AlertView still visible, after all the user did not dismiss it. So, what is the best way to go about this? Have the button simply load the veiw from a nib, and add it to the subview of the parentview of alertview, and then hide it when the exit button is pushed? Seems kludgy and boring, but I assume this would work...
Store the fact the alert view is visible in a modal variable, and on the ViewWillAppear check the modal, and then redraw the UIALERTVIEW? This seems like a memory leak to me, since the original view was never explicitly released...
I got to believe there is a more elegant solution... any ideas anyone?
Well, in the end I just wound up just recreating the alert view after the secondary view was dismissed. I can't say I'm crazy about it, but it does provide the behavior I need without lots of hacking.