iOS AutoLayout - Button moves when app is launched - ios

I will try to describe this issue--never seen this behavior before.
I have a button that moves from the right of the app's screen to the middle when the app launches on the simulator or actual device. I want it to always be in the middle (where it moves to).
Basically, it moves from one position on the parent view to another position (I want it to ALWAYS be in the position defined by the constraints)
How do I accomplish this?
Here are images to show the behavior and the constraints:
Button is on the right, higher up; then fades out
Button fades in to the bottom, centered position (correct per constraints listed below)
Button constraints:
Button.centerX = centerX (center the button to the container's horizontal center)
Bottom Layout Guilde.top = Button.bottom + 112 (anchor the button to the bottom of the app regardless of screen size or orientation).

Just add two constraints BottomSpace and CentreX as below. (And if required explicit height and width)

1.Also provide button.left.
Or
2. Use constraints show in image.

OK, I fixed the issue. Somehow, the splash screen storyboard got a copy of the button and other views that i had on the main storyboard. Once I deleted the button from the splash screen story board, the button issue stopped.
Apparently the first screen shot was the splash screen, and the second screen shot was the actual app (main storyboard).
Thanks to everyone for trying to help!

Related

positioning UIBarButtonItem vertically (for iPhone X)

I'm trying to compile my app to work correctly with the iPhone X, using all the available screen space and accommodating the new home indicator at the bottom of the screen. My app has a bottom toolbar, and I notice that Apple's apps extend the height of the bottom toolbar to give extra room for the home indicator. I give my toolbar extra height, but the buttons themselves want to position toward the bottom instead of the top. Is it possible to force them to align toward the top of the toolbar instead of toward the bottom?
Thanks.
In the app for which I asked the question, I am positioning views on the screen using coordinates. (In a constraint based app, one would need to pin the bottom constraint of a bottom toolbar to the safe area rather than the superview; if you are using the built-in bottom toolbar belonging to the navigation controller, the position of the toolbar and its content will take care of itself). Surprisingly, the solution turned out to be simply lifting the bottom toolbar up using its y coordinate, no more than 34 pts, and the area below the toolbar and near the home indicator will simply assume the color of the bottom toolbar, making it appear as though that area is part of a taller-than-normal bottom toolbar. The buttons on the toolbar will no longer appear squished.

iPhone X tool bar issue at the bottom

My app works well on all device except for iPhone X.
On iPhone X the tool bar on the bottom is shown like as shown in image
But I want to show it like shown in second image
But when ever I shift the tool bar up so that it will show properly on iPhone X then it also move upwards in other devices.
How should I solve this problem.
Actually the bottom bar of my view is inside another view thats why it is not extending accordingly.
So simply putting the bottom bar outside, on the main view and adjusting the constraint simply resolve my issue.
In my case My toolbar's bottom constraint was attached to superview's bottom. Changing it to Safe Area bottom resolved the issue for me

bar button is not showing on the navigation bar at run time

I am following this tutorial, and as shown in image-1 below, I added the "Add" bar button, but when I run the simulator it does not show up as shown in image-2.
please let me know why the "Add" button is not showing and how to fix it.
image-1:
image-2:
Two possible scenario :
Scene 1 :
Looks like you are using iPhone 6s Plus simulator and 100% zoomed. So I could see horizontal and vertical scroll both. I believe the Plus button is still there its just that u have to scroll to see it. Even the title Players is not in center :)
Use Command + 3 to zoom out the simulator and see the O/P without scroll :D
Scene 2:
If you have added Navigation bar manually make sure you add top, leading and trailing constraint to Navigation Bar. The Nav bar you added is bigger than iPhone 6 plus size and because there is no auto layout constraint added it might have extended beyond the screen.

iAd Banner disappearing on 3.5", but shows on 4" screen?

I am doing a simple one view layout, calculator style app. I have multiple input fields, where values are entered, and a calculate button. All this works well. When I change size to 3.5" screen, the iAd banner I have at the bottom of screen disappears. When I switch back to 4", the banner is back. How do I lock down the banner to display at bottom of screen regardless of screen size? Thanks~
Hopefully you're using Autolayout. It takes a while to understand, but when you do it is extremely powerful for laying out flexibly for multiple screen sizes.
Anyway, assuming you are using Autolayout:
Here's my ViewController with the banner ad at the bottom
I select the banner and then click "Pin" - I then add the constraints that you can see in the image - click "Add Constraints".
Now, if I view how it would look on a 3.5" screen, it is still fixed to the bottom.
This can be happening because the Autolayout. Go to Storyboard, select the iAd view, then click on the segment "Pin" (third button on the bottom of Storyboard) and add the bottom Constrain.
Hope it helps.

Portion of iPad simulator screen responsive to swipes, but not button clicks

I have a UICollectionViewController in a container. On a specific portion of the screen (bottom right area in Landscape), it will register swipes, but the sections of buttons in that area are non-responsive.
The buttons are the top items in the view, so nothing overlays them. Only a portion of the button is non-responsive, and only when it is in that area of the screen. It is consistently the same area in every collectionView that is in a container.
Has anybody encountered this issue? Any potential causes or fixes?
Figured it out. I was using "freeform" viewControllers, and they were messing with my superview size. So, as rdelmar pointed out, my problem was that the buttons were outside the superview.
I solved the problem by deselecting "Resizes View From NIB" in my freeform viewControllers.

Resources