xcode button appearing under tabbar - xcode

I am using auto layout for everything and I have some buttons that have been snapped into place above the tabbar and in a corner.
The inspector shows no constraints on this button placement. Simulating on a 4 inch screen works fine, but when I simulate on a 3.5 inch screen the button is underneath the tabbar. Why is this happening? The button has "snapped" into place in the corner there so shouldn't auto layout take care of the rest? Or do I need to do something else?

If you have no constraints on an item, then it's placed to a concrete X/Y measured from the top left corner.
If it's in the right location on the 4" screen, then it's at a Y much lower than will look correct on a 3.5" screen. When on a 3.5" screen, the X/Y coordinates will still be measured from the top left corner, 400pixels is much closer to the bottom of a 3.5" screen than it is a 4" screen. If it's 3.5" from the top of the screen on the 4" screen, it won't even be on the screen on the 3.5" screen, etc.
Set your constraints, or adjust the button's location in viewDidLoad based on [[UIScreen mainScreen] bounds].
I recommend the official documentation on autolayout and setting constraints.

Related

Xcode 10 View Controller Scene Positioning Problem

I have inserted a label into my View Controller and centred it to the middle. When I run the app on the simulator for iPhone 6 the label is not centred.
I have tried adding constraints to the label. When running the app in the iPhone 6 simulator hides the label completely. What am i doing wrong?
Make the background color of the label to a darker shade.
If there are any red constraints, try to eliminate them
The best method to centre a label is to select the label from the structure hierarchy, click on to the Align button in the bottom, select Horizontally and Vertically in Container to be at 0 value

Extending clickable area of a standard Win32 button?

I have a button which, due to margins (and it looks better this way) is 3 pixels from the edge of the screen. I'd like it to highlight on mouse-over in this margin region, so that it can be clicked by moving the mouse to the side of the screen.
Is there any way to extend the clickable area of a standard Win32 button, such that the button believes its clickable area to be larger than its drawing area?

What will be the constraint for equally spaced buttons in swift programming?

[When i run this in Xcode beta, only left most button is visible. Other buttons seems to be collapsed. Can somebody help me on this to fix the constrains for the 3 buttons, please?][1]
http://i.stack.imgur.com/UOGLO.png
For me, it works when I set the width for one of the buttons (in the screenshot below the one in the middle), for the other buttons the "equal widths"-constraint.
For the horizontal and vertical position I centered the button in the middle and set its space to the top to a fixed value. The buttons on the left and on the right are then centered vertically to the middle button. Like this:
http://i.imgur.com/1UJsKmi.png
The current best practice for this kind of task is to use UIStackView if possible (iOS 9.0 and up). You can just place all three buttons in a UIStackView on the storyboard (or in code), set its distribution property to "Equal Spacing" and just set constraints on the overall stack view itself to make it as wide as your overall scene, etc.
There's a good video overview from Apple here:
https://developer.apple.com/videos/play/wwdc2015/218/

Auto Layout view resizing frustrations when designing in Interface Builder

Problem: UIView size is "locked" when designing with Auto Layout in IB
I've uploaded a 20 second video that illustrates my problem, but let me describe it. You may recognize the project: it's right out of Apple's WWDC 2012 "Introduction to Auto Layout." I've got a simple iPhone view in Interface Builder where I've already got a button and label along the bottom. The next step is to add a UIView. Here's where things get ugly.
When I drag the UIView out of the palette in Interface Builder and onto the iPhone window, as soon as I let it go it seems to become locked in to its starting size. I place it in the upper left corner, and I'd like to drag it horizontally to the right side of the window, and vertically to where it will be up against (minus the padding) the button and label along the bottom. But, when I try to resize it, I cannot. It's stuck on its original size!
The video illustrating my problem is here:
http://www.youtube.com/watch?v=jsW4UwnCEkw
You can see me grab the right edge of the view and try to pull it along to the right side of the window, but it won't expand. You can then see me move the entire view to the right side (it retains its size) and then try the opposite: grabbing the left side and trying to expand it so that it sizes up against the left side of the window. In both cases, the view is simply locked to its original size.
What gives! Auto Layout in Interface Builder is just the most frustrating thing. How do I resize a view by dragging? Thanks!
(Note: Xcode 4.6.3.)
In IB, in the series of buttons in the lower right hand corner, click on the rightmost button:
When you do, you'll see a "When resizing Views Apply Constraints To..." pop-up menu:
Make sure that "Siblings and Ancestors" is not checked.

Xcode Implementing scroll with animation

How to implement a scroller to one of the labels before reaching the top of the screen has remained at the top, and the text scrolls from another label beyond the limits of the screen, such as in instagramm, except instead of photos text from the second label
Scroll View
scroller to one of the labels before reaching the top of the screen has remained at the top, and the text scrolls from another label beyond the limits of the screen,
http://www.youtube.com/watch?v=mws6Zbq_y6c
Darwich

Resources