iOS - Swift - How to display UIAlertViewController without disabling background - ios

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/

Related

Dismiss iOS form sheet modal via outside tap + VoiceOver mode

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.

UIPopoverController Button, Prevent Dimming Overlay?

When presenting a UIPopoverController from a UIButton the entire screen behind the popover is dimmed.
Is it possible in some way or another to prevent the presenting button (the one pressed to show the popover) from being dimmed?
I remember solving this problem when it has appeared the first time on iOS 7. The only solution (if nothing has changed) has 3 parts:
Remove the default background (setting popoverBackgroundViewClass).
Add your own background (I used a subclass of UIPopoverController to handle the appearance callbacks)
Display your button (or any other passthrough views) above the background. You can either remove them from their hierarchy and move them to the same position in the background or just take a screenshot of them and add them to the background.
In the end it's not too difficult but it takes time to debug.

Add an inputview to UIButton for on click event iOS

I am building a page for a Swift iOS app and I want the user to be able to specify the date range for a graph. At the top of my graph I want the user to select a date range by clicking on a button which will gray out the screen and bring up a picker view on the bottom of the screen to select the date range. It's very similar to how the myfitnesspal app does it (below):
As you can see when they click on the calendar button it brings up a pickerview while graying out the rest of the screen and only recognizes touches to the pickerview. I basically want to replicate this kind of method that allows me to bring up a custom picker when a button is clicked.
I have tried using UIActionSheet however that is now deprecated and I've read that an action sheet should not be used for this kind of functionality.
You can do this by designing a view controller such that-
It has a background view that covers entire screen with background color as black with some alpha say 0.3. This view will serve to block out any touches on the views behind it. Basically it will have that translucent background effect.
Have your actual view such as picker view as a sibling of this, add other siblings like the cross button, etc. You can use the cross button to initiate closing of the view.
Present this controller as a child view controller on the controller where you need this.

iOS popover with a close button outside

I need to create below thing
Currently i'm using WYPopover , but I can't create the button since it's outside of the popover. Is there any existing solution out there ? Many thanks
Create a bigger popover UIView holding all your child elements (current popover + button) and make its background transparent or however you wish.
Popover-controller's are exclusively used in iPad. If you want to use in iPhone, you should create it in a custom way.
I am not familiar with the XYPopover in Github, but normally the custom created popover should be dismissed whenever the user taps any place in the screen. That is one of the key feature of the popovers.
Normally the custom popovers are build like, adding a hidden parent view and then the visible image of a popover frame on it.
You should to do the following,
Avoid dismissing the parent view on tap of parent-hidden-view.
Add a close button at the area where you want to show the close button, on top of the parent-hidden-view.
Capture the button click and dismiss the view (remove the view from superview)
How to customize your need
Creating custom popover view is not a big task. It will take maxim one day, try it your self.
One Parent view with clear color
One background image of a popover frame.
View-inside popover (this needs to be customized for UIPopover also).
Close button.

iPad popover view

I am having an issue with the UIPopoverController. I am trying to make a registration form appear on the screen when the app starts (and a login screen periodically thereafter). However, as the form is a little long I also require a toolbar that sits above the keyboard, with next, prev, done buttons (similar to those found in safari).
How can I make the toolbar appear on top of the popover view, while still maintaining a full width of the screen, the iPad is constantly in landscape mode.
I did have this working, however the buttons would only be active when they appeared in the same rectangle as the popover.
Any help here would be appreciated
Set your toolbar to be the inputAccessoryView for each of your UITextFields.
There are many examples of how to do this on SO and other sites.
Create a Class for your Previous,next Toolbar.
Make a method which return a Toolbar as below.
-(UIToolbar*)createToolBarForView:(UIView *)keyBoardView
{
//Add segment Controller and Selector for your segmentController
}
In the selector for your segment controller Use Delegates to notify the implementing Class that segment controller is getting fired.
After Making all these things set the inputAccessoryType for all the textFields for which you want that toolbar to appear
{
YourTextField.inputAccessoryView = [OBjectOfYourCustomView createToolBarForView:self.view];
}

Resources