View is different during preview and run time - ios

I am creating a sign up page. When i run this on the iPhone 4s, part of the Sign Up button is being covered up. Therefore i decided to add a scrollview. On the left side is how the screen looks like in the storyboard and on the right is how it looks like during preview.
However when i run it, this is what i get
Why is the label pushed down by so much? I have added a red background to the scrollview. The scrollview starts right below the navigation bar. But the label is being pushed down by so much. Why is this so? and How do i fix it?

Looks like some constraint error. I am not pretty sure if you using or not. My advice would be; add some fixed height of the label. Make sure that the "Sign Up" button has bottom constraint, too.

Related

Swift: Setting View on top of SceneView not working

I'm trying to set up a layout where a Map is placed on top of the SceneView. When the app builds, the set up flashes for a second, and then the SceneView takes up the whole screen, completely hiding the other two views.
After moving the SceneView on the left hand menu and moving it back, the text started appearing but not the black background.
(I've got constraints set for the Scene View to take up the whole screen, and some constraints (right and bottom) on the Map too.
Why is it not working?
EDIT: It started working after I deleted the view and added it back in, but not sure why. #El Tomato says SceneViews always overlaps other views. Is this true (i.e. by accidentally getting it to work, am I utilizing a bug)?
It is doable. I'm doing it currently with an app I am using, but the difference is that I didn't set up the ARSceneView in the Interface builder, but I added it to fit the whole screen programmatically. I have some buttons that were added through the interface builder, and I added a label with a background now just to make sure it works similarly to how you want it.
I will post some images:
Here i simply have the view controller with some (bad looking buttons) in the stack View as well as the label with a red background. The ARSceneView is added in the my ViewDidAppear function and takes up the whole frame.
This picture is from the screen while the app is executing (Debugging the UI). As you can see, the Label with the background as well as the buttons I've added all show.
I also have 2 buttons that are showing as well (the white and red circle) and these were added programmatically and were brought to the front.
My suggestion is to try and add the ARSceneView programmatically, maybe it doesn't work otherwise. Or you can try to outlet all your views and bring the Map View and the Label to the front using bringSubviewToFront.

Limit AutoresizingMask height stretch

I made this screen
Screen on iPhone 4s(9.3)
It looks fine on that device, however when i test this same screen with iPhone6(9.3) it looks like this. Since i cannot post more than 2 links, i merged the third image with the second one
Screen on iPhone 6(9.3) with the Third Image
As you can see, that gray view, doesn't fill the white space beetwen that same gray view and the first bottom button(lojas). Notice that i don't have the autoresizing height stretch on(that vertical arrow inside the blocks). If i turn that on, this happens
Third Image inside the Second Image
See that, the gray view goes over the buttons, i don't want that.
My question is, how can i solve this? Is there a way to make the gray view stop above the Lojas Buttom at the bottom? Thanks for your time!
OBS: I CANNOT use autolayout.
EDIT: Got the problem solved
I just changed the View as option in Interface Builder, changed it to 7.0 and later, so it gave me the "real appareance" of the app.
I changed the View as option inside the Interface Builder so i could see how the app really look like and set the iOS Deltas to 0, made the changes based on that.

navbar dissapearing in preview and simulator when setting constraints

I'm currently following the udemy ios8/swift course and I'm completely stuck on the navigationbar part. I'm thinking it might have something to do with the fact that I'm on a higher version of Xcode, but can't seem to find the solution.
I have to set the constraints for the navbar on 0 on 3 sides so it will be centered and full width in both landscape and portrait mode. When I try to do this, I see a option thats not there on the course (Constrain to Margins). No matter how much I try to adjust the values, the navbar keeps disappearing or moving in the wrong direction. I tried unchecking the constrain to margins function and putting everything on 0, I tried 'resetting to suggested constraints' and lots of other options, but I can't seem to get my navbar look good in both landscape/portrait mode. So basically, what am I doing wrong or is there any other way to do this?
In addition to the three constraints you need to give the navigation bar a height.
Another solution is to add a navigation item to the view controller instead of a navigation bar. A navigation item will auto format a navigation bar at the top of the view.
I've been able to fix it by manually setting the constraints to 0 in the Attribute inspector after Ctrl-dragging to create them first. Not sure if this is the ideal way, but it solved my problem for now.

Views resize after pushing a view controller

I'm having a really strange behaviour. When my app starts everything is fine: the size of the views on screen are exactly the one specified in the storyboard. But just as I try to push a view controller its contents are scaled, so when I pop back the view is messed up.
Any clues?
First learn about Autolayout. Here is a good way to go
Autolayout
Second I am giving you a trick which may work.
Click on viewController
If you don't want your views to extend their edges to bottom or to the top deselect Under top bars and Under Bottom bars

Simple Horizontal Button Bar for iOS

I have a requirement for a very simple Button Bar.
It should take up the width of the screen.
It should allow at least 3
buttons.
The buttons should be of equal width and together take up
the whole width of the bar.
Each button should be tappable, but not
have a selected state.
The bar will be overlaid on a MapView and positioned directly above a TabBar.
Tapping a button will launch a Modal ViewController.
I thought about using a UITabBar and not allowing its tabs to become selected, but the HIG is pretty clear that this is not correct usage and UIToolBar doesn't allow the button widths to be set.
This seems like a very simple requirement but I can't see an obvious solution. Is there something I'm missing? Can anyone suggest a solution?
What's wrong with just creating a simple view that draws an appropriate gradient, and then adding three buttons of the appropriate size?
If you're feeling ambitious, or if this is something that you're likely to use more than once, you could even have the view create the three buttons. Call it ThreeButtonBar or something. Give it a constant height and adjust the width to match that of its superview so that you can use it in portrait or landscape orientation.

Resources