Horizontal slider disappears when using constraints in Xcode Swift 3 - ios

I have a horizontal slider that appears and works fine. But when I add any constraint, it disappears from the build. I've also done an archive and tried it on my real iPhone 5c device.
Any ideas what could be causing this and how to fix it?
Screen in Xcode, showing constraints:
Screen in preview (same on real device), and it does not appear:

It looks like you haven't set the y position of the slider view. You need to hook that up too, that should fix it.
On the left side of the storyboard, there is the overview of your ViewControllers. In the upper right hand corner of the one, you're currently in, there should be a tiny warning symbol:
If you click on it, you will be presented with what might be the issue:

Related

iOS/Xib: Easiest way to show a button in the middle of different iPhone

In my iOS app, I just want to have a button located in the middle of screens of multiple devices (like iPhone 6, iPhone SE, iPad Air).
However, surprisingly, it seems not intuitive to do (at least not as Android) in XCode + Xib.
Following shows a trivial example of this problem where I put the button aligned to the middle:
However, unless the "dimension" of the view is set identical to fit the installed device, there is no way to display the button in the middle.
Add horizontal and vertical center constraints as follows and it will always keep your button at center of any screen as shown in the image below
You can also add distance constraints to borders of the screen :
Example

App resizes on deployment to iphone 6s - xcode

I have a simple single screen app with two buttons that looks great on the story board on xcode. As soon as I run the app on my iphone 6s, it resizes the screen and the buttons at the bottom disappear. It looks like the resolution has changed and the app is not meant for an iphone 6s screen.
I have already tried the following without any success:
1) Enabled "Use Auto Layout" for my View controller in the File Inspector menu(under utilities)
2) Set the deployment target to "10.3", Devices to "iPhone" and checked "portrait, landscape left and landscape right" for Device orientation under the General Settings.
Is there any other setting that I might have missed to check that is causing this scaling? I am using xcode 8.3
Edit: I recieved some great feedback in the comments section, and learnt about adding constraints. I am here adding screenshots of what my app looks like before and after adding constraints:
Here is my xcode storyboard (what I am looking to get on my iPhone 6s)
And here is a screenshot of what I have on my phone (prior to constraining)
I have tried constraining the view like so with no luck (same output on the phone):
Is there a specific set of constraints that will do the job here?
Your screenshots show that you have not set your constraints. The last screenshot shows that you have set some constraints on the root view. Like mentioned by Martin you need to have constraints for each object.
To place the button correctly at the bottom of the view, you need to draw from your button to your view (holding the ctrl-key) and then select the bottom, leading and trailing constraints.
I suggest to make a beginner tutorial in Autolayout with InterfaceBuilder.
Thank you for your great responses. Turns out the solution was a little different than just experimenting with constraints. It took me about 3 hours to figure this out, and I wanted to share the simple solution here in case someone else goes through the same thing in the future.
The problem was in the General section of the settings. Your Launch Screen File must reflect the MainStoryboard like so:
My Launch Screen File option was previously set to nothing which caused the problem. As soon as I changed it to the MainStoryboard, things look just fine.
Hope this helps someone!

Why is iOS simulator displaying blank screen when I rotate device?

Getting through some introductory swift and playing with Xcode and I basically just have a page with some color squares, background color etc. Doesn't do anything. Problem is when I compile the code it will run in simulator just fine and show everything perfect, BUT when I rotate the device, everything disappears and it only gives me a blank white screen. Rotating right or left does it. The only view that shows it is the original upright view (for all iPhone devices that I tested on through the simulator).
Xcode 6.1.1 and iOS Simulator 8.1 are being used on my MacBook Air with OSX 10.9.5.
In the App general page, I have already checked under Deployment info that Landscape Right and Left are both checked on. Storyboard is set on Any H and Any W.
I'm not sure what I'm doing wrong and it has been pretty difficult searching since I'm still new to iOS development I'm not sure I'm using the right words or whatever because I can't find an answer.
Summary:
App displays properly in iOS Simulator, Portrait View but no other views work and will display blank white screen instead.
In order to see if your views are actually being drawn and just off screen as others have suggested capture the view hierarchy. Go to 'debug' in the menu, then in 'view debugging' click capture view hierarchy. This will pause your app and create a 3D representation of all view on your screen which you can move around by clicking and dragging.
Are your views actually being drawn? If yes are they drawing off screen? If yes then you need to fix your constraints.
It sounds like you haven't set your constraints appropriately. Try setting the top and leading constraints for each of your views to something less than 320 (should cover all device sizes). Fix your warnings, then try again. I believe the views are simply off the screen.
You don't have the correct auto-layout UIConstraints set in interface builder. Check the document outline view in interface builder and ensure that you have appropriate constraints set on each view.
Auto Layout issues occur when you create conflicting constraints, when you don’t provide enough constraints, or when the final layout contains a set of constraints that are ambiguous.
Check this Apple documentation out, it will show you step by step how to resolve your (common) issue.

Xcode 5 - Switched to Landscape orientation, content not centered anymore

I switched to landscape orientation and I have a button and slider in my very simple app. In the live view in Xcode, the content is exactly in the middle of the screen (snapped into place). However when I run the app, the content is slightly shifted to the right in the Simulator. Anybody have any idea how to fix this?
http://imgur.com/vfdO6N8
http://imgur.com/vS816p2
If you're using auto-layout try to add Constraint like this.
Click the issues Button
Then click on 'Reset to suggested constraints in Window'.

UIStepper Not Visible

Via storyboard in XCode 5.0.1, I've added a simple UIStepper in my ViewController. However, I've noticed that when I place it up towards the top of my screen where I need it it doesn't actually appear in the simulator nor on the device. I thought I was going crazy so I created a test app outside of my regular working project to prove I wasn't--as it turns out, I'm not. I placed it in a simple view and noticed the bottom edge of it up at the very top of the view. (I wasn't seeing it at all in my original project because I had a nav-bar at the top.)
The following images show it as it appears in the storyboard (UIStepper visible) and on the simulator/device:
(Storyboard)
(Simulator)
Two questions: Is this a bug? Other than guessing where it should appear and setting its frame origin manually what would be the recommended approach to ensuring my UIStepper shows up as I've placed it in the storyboard? (I'm afraid manually setting the frame origin would break or mis-align in future iOS versions.)

Resources