How to make a UIDatePicker appear at bottom of screen? - uiview

I currently use MonoTouch with MonoTouch.Dialog. When tapping on a date field it pushes the navigationcontroller so you go right a screen to see your UIDatePicker where you choose the date then go "back" to the main screen again. I'd really like to have this UI like other apps I've used that when you select a date field the UIDatePicker appears at the bottom of the current screen.
I would like to learn how to do this and apply it to other input fields where I may want to use a custom picker that also presents itself at the bottom of the current screen.
Does anyone have any code to share that would allow a UIPicker/UIDatePicker to appear at the bottom of the active screen?
Thank you.

You just create a UIPickerView normally, but set its frame outside of the visible area. Once you click on a cell, you change the origin point of the UIPickerView's frame, so that the picker view will become visible. You can animate the property frame, so you can make a nice soft animation that your picker view will slide in from the lower boundary of the phone.

Related

Issue with displaying an alert like view

In Android, on the click of a button I get a screen coming up (the one on the left with just the First Name and Last Name) and on click of the more button the other fields are also displayed (the image on the right).
I tried to achieve this by loading another view on the click of the button, but this shows a view completely filling the screen and not like the one in the image with limited height and the background view being greyed out.
Also to get a screen like the one on the left I made their height constraints equal to 0, but though it showed just 2 textfields, the screen filled the whole screen and not like the one on the left.
Any idea as to how this can be achieved?
To show custom transition while presenting a controller i.e.
your first requirement - a view completely filling the screen & not like the one in the image with limited height and the background view being greyed out.
you can use UIViewControllerAnimatedTransitioning.
I have created a sample here:
https://github.com/pgpt10/Custom-Animator

UIPickerView modal with already visible toolbar attached

(See Sketch)
How would I implement this behaviour with an already visible toolbar? Also, the little information I found on opening a UIPicker modal are all based on using a UITextField which is not what I'm aiming for.
What I'm looking for is a button on the toolbar opening the picker modal with the toolbar attached to it. Button1 on the sketch is simply to select a value the user is most likely to pick (Something like "Go to todays date"), and done should hide the modal and bring the toolbar back to it's original state of being attached to the bottom of the screen.
Ideally, I'd like this toolbar with the picker functionality to be avaiable on multiple views.
You could add constraints to your storyboard, connect them as outlets to your code and then disable and enable the appropriate ones whenever needed.
One constraint setup would be:
add a constraint that pins the top of the picker to the bottom of the view
add another constraint pinning the bottom of the picker to the bottom of the view
-> If you enable 1 and disable 2, the picker is hidden
-> If you enable 2 and disable 1, the picker is visible
That change in constraints is animateable which will result in a smooth UI change.

tab view like button slides up

I am trying to have a button that is located on the bottom and when the user taps on it it will slide up to show the menu. How is this possible using code or is there an api or anything that I can use to make this possible in the easiest way?
Your screenshot shows a view whose frame is animated when the button is pressed so that either the height of the view, or more likely just the position, is changed so that the view becomes visible. This is a simple UIView animation and the view being added so it is hidden behind the button initially.
Check out the iOS documentation for Animating Views https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/AnimatingViews/AnimatingViews.html
You should be able to create the view and its content either with the interface builder or in code. Start with the view off the bottom of the screen and then use animateWithDuration:animations: using the frame property.

Picker View displaces objects

I'm making an app with a picker view, and when a button is pressed, the picker view pops up, and when another button is pressed, it disappears. In the storyboard, the picker view covers the bottom half of the screen, including two buttons, but when I run the simulator, the buttons and other objects that are on the screen (such as labels and text fields) get shifted to seemingly random places, including the objects that are not covered by the picker view. What exactly is the problem, and how do I fix it?
Go to the story board, select that particular view controller on which you have placed the picker view and open document outline window(which appear on the left side of story board). After that you will get the list of components present on that view. Drag the labels and the buttons to the bottom of the picker view. By doing this you will get the labels and the buttons on the top of the picker view and add the constraints to the components.
Another reason might be that you have selected other model at the bottom and ran on other model.
Just set the constraints it will solve the problems. And delete suggested constraints.

uitextview keyboard appear above uitoolbar

I have a uitoolbar at bottom of my main view. I also have a uitextview at top of my view. when tapped on the textview to start editing I want the keyboard to appear from above the toolbar, not covering the tool bar. I want to know how I can do that also I don't want it to be animated.
I have one more question, when the keyboard appears is it possible to put another view in front of it?
thanks
You can't do the former. The keyboard is in a different window and so doens't interact with the views in your window. Apple doesn't provide any public access to the keyboard window.
As to the latter, putting a view in front of it, you might be able to something like that by creating another window but I've not seen anyone do it and not sure what it would do to the keyboard events, etc.

Resources