Picker View displaces objects - ios

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.

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.

Why does Interface Builder show hidden views through the views above them?

When nesting views in Interface Builder, if I have an opaque view with hidden views beneath it in the view Hierarchy, the hidden views are visible through the higher view and are just partially translucent like the below picture.
Why does this happen and can I make it stop? It's very annoying.
To be clear this is strictly in IB. At run time the views are displayed correctly.
Sad to see this is the best answer that I have found so far: If you set the view you want to work as NOT hidden, while all the rest ARE hidden, then you can select away from the storyboard (e.g. some other file), then click back on the storyboard. Only the NON-hidden views are displayed. Sadly, the other views comeback if you make position alterations to the view (UPDATE: only when you click and drag. Selecting and using arrow keys does not), but changing text, size, color etc do not.
Original with hidden
Clicked off storyboard and back

Creating a custom tab view, with each tab containing a scrollview

Im trying to create an inventory page in an ios game. My design is to lock the view to landscape, then use half the screen for the "bag" or inventory (this is the tabs). The other half would be a display for details + menu controls
By selecting each tab, the corresponding view should be brought to the front of the view. Each view contains a scroll view and a static background image. The image is slightly bigger than the scroll layer since the image carries a border.
Since i only want a partial part of the view to be a tab view, i cant really take advantage of uitabbarcontroller.
Any ideas?

How to make a UIDatePicker appear at bottom of screen?

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.

Resources