Add an inputview to UIButton for on click event iOS - 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.

Related

Name of the View or iOS Component used in the gif?

This is the way i need to create (gif).
The Above gif shows a view which pops up from bottom while clicking on the moto g3 button overlaying the parent view with some gestures to control it.
I would like to know the name of this view if available in the iOS components or any specific ways to create it.

Objective c - Create a tutorial bubble that will hide in background click

(First - i'm sorry about my english:).
I want to create a tutorial bubble that will pop up in some situations while using my app.
I need this popup to disappear when clicking or scrolling on every view in my VC, and i need that these buttons to do what they need to do in this click event and not only dismiss the pop up so then we will need to click on the buttons again.
I have 2 ways to do it, but every one of them have some disadvantage.
the popup view will have a transparent view with frame of the whole VC. this background view will dismiss the pop up in its touchBegin event.
but like that i can't click ob my buttons that below this popup background view.
the second option is to create the pop up without the background transparent background, so all the buttons will be clickable.
but in this situation i don't know how to listen all the buttons click event or table scroll event so i can dismiss the popup.

iOS - Swift - How to display UIAlertViewController without disabling background

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/

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.

Should I use a tab bar or button at the bottom of my ViewController?

I'm just learning iOS, and I want to create an App which will have a few buttons at the bottom of the screen.
What I'm a bit unsure about is, I know you can use a tab bar down there, but is that what you should always use when you want a button at the bottom of the screen? or there's no need to use a tab bar, and you can just put a normal button down there?
According to apple's documentation, UITabBar is a control used for displaying views.
A tab bar is a control, usually appearing across the bottom of the screen in the context of a tab bar controller, for giving the user one-tap, modal access to a set of views in an app.
If your goal with this "button" is to display other views, then you should use UITabBar component.
But if you are just searching for a "usual button", then you should use UIButton component.
A tab bar is expected to allow the user to switch between, you know, tabs; the same bar appears at the bottom of each page, and it allows you to switch between them. If that describes what you are trying to accomplish, then it would be appropriate. If your button is meant for some different purpose, then a tab bar might be misleading.
A tab bar (class UITabBar) is usually part of a tab bar controller (class UITabBarController). A button (UIButton is simply a way to respond to a tap or other actions within the button.
You want to use a tab bar and tab bar controller when you need to switch between different views and view controllers in your application. For example the Music app on your iPhone has a tab bar controller that switches between Artist, Playlist, Album, etc. These are different screens, or screens that look the same but show your music organized in a different way.
If all you want is to respond to a button, for example to print out to the console or show a message to the user that says "Hey, you've tapped the button", then a UIButton is what you need.
Also, a UIButton can have many actions, Touch Up Inside is probably the one you are looking for. This one will ensure the button has an action called if the user began a tap on the button, and let go of their finger while still on top of the button.
To summarize things:
Use a UIButton if you simply want to respond to an action, and the most common action you will connect to the button is Touch Up Inside.
Use a UITabBarController to have a way to switch between different views and view controllers.

Resources