Can't place a WKInterfaceButton underneath another one in watchOS storyboard - xcode

I'm building a storyboard for my watchOS app in Xcode 13.0, and attempted to place a new WKInterfaceButton underneath an existing one.
The new button refused to go beneath the other one. I dragged it underneath the other one multiple times, I deleted the new one and replaced it with another, yet it wouldn't go down.
The storyboard should be laid out as followed:
Label (placement already set up)
Button (placement already set up)
New Button (being annoying)
How would I be able to place it underneath the other button?
Link to video showing the issue: https://imgur.com/a/oZaHxfF

Double check the 'Attributes Inspector' for both buttons to make sure the alignment is set correctly.
If the Refresh button is set to bottom, other elements will always 'float' above.

Related

Xcode issue changes Storyboard elements position when a project is opened

When I open some of my project I notice that the editor automatically set the bound rectangles on and shift every UI element of the ViewControllers slightly to the left.
I don't know how to fix this without having to manually correct Views every time this issue pop up.

Why isn't storyboard safe area working correctly on iPhone X?

I'm trying to update my app for the new iPhone X. After reading about the safe area feature and the check box "Safe Area Relative Margins" in each UIObject's "Size Inspector" (ruler tab), I didn't think this would be too bad. However, that feature does not seem to be working for me.
Nothing changed for regular iPhones, which is good, however for the X, the top of my app overlaps the top inset of the phone by a third. Is there any known way to fix this* or something I'm missing?
*By fix this, I mean make it so that my objects start below the outcrop, like the second picture.
What is happening:
Desired Behavior (from https://arstechnica.com/gadgets/2017/11/how-devs-updated-their-apps-for-the-iphone-xs-screen-and-the-notch/):
I too have wasted hours on this. And while I cannot answer your question of why this is broken in Xcode, I can provide a solution.
But first let me note than in Xcode 11.3.1, I experience the same issue in a new project created from scratch.
Set up your storyboard:
On your storyboard, select "Use Safe Area Layout Guides". This will add a safe area to each of your ViewControllers. It will also require you to target iOS9+. You might be able to skip this step though (see step 4 below).
View your storyboard as iPhone 4s.
Fix each ViewController:
Select all views under the top-level view.
Click Editor | Embed In | View Without Inset. This creates a new view and puts all your views inside.
Make this new view expand to the safe area by adding safe area constraints (by control-dragging your new view onto the top level view).
Leading space to safe area
Top space to safe area
Trailing space to safe area
Bottom space to safe area
If you did not opt into using a safe area storyboard above, you may be able to create four equivalent constraints by using the Top Layout Guide, Bottom Layout Guide, and the left/right sides of the top-level view. This may not work in landscape though. And I did not test this.
Set your new view as transparent.
Give your new view a name like "SafeAreaView".
In iOS 11, margins are inset from the safe area. Thus, your zero top margin becomes a 20 top margin — explaining your screen shot. If that's not what you want, set the view's insetsLayoutMarginsFromSafeArea property to false.
In my case modalPresentationStyle = .fullScreen has to be set to the view controller being presented

Labels in XCode View, positioned differently in Simulator?

In XCode 7, on a Swift 2 project, when I place a label onto the View, why is the label centred in XCode, but in the Simulator it's show off to the right?
This is just playing at the moment, where I don't want to play with constraints just yet (which I believe will be used later).
I had the same problem when working through a demo, and this worked for me. Try using the 4.7 inch size view controller:
Look in the middle left hand menu (the Document Outline), if not shown it’s under Editor > Hide Document Outline (a misnomer, clicking it will Show or Hide it).
Click on the View Controller so it's highlighted.
Click on the 4th tab of the right hand one (Utilities: the Attributes Inspector). If not shown it’s under View > Utilities > Show Attributes Inspector.
Under Simulated Metrics is a Size option to change from “Inferred” to “iPhone 4.7-inch”.
You'll need to realign things again, but now these should look central in the View and in the Simulator.
Constraints, when you want to get to them, will probably be more helpful in this regard.

Detail View on Storyboard too zoomed in - creates misaligned objects in simulator

I have perhaps a beginner's question but have not found any solutions addressing this specific problem after searching endlessly on stackoverflow and other forums.
My detail view in the storyboard appears to be too zoomed in. At this point, zooming in and out simply zooms in and out on the storyboard, but not the detail view specifically.
Indicators of this are that the alignment arrow to the left of my button is not positioned at half-latitude of the Detail View box, although when I align my button to this marker I do see a crosshair indicating that my button is "centered".
Detail View - Further Out
Upon simulation, it is apparent that using these crosshairs produces a run-time alignment far right and up from being centered. Where my button is currently placed seems to be in the center of the simulator screen but would like my guidelines to allow the button to be centered using the guidelines suggested.
Simulator View
A) How do I "zoom out" within the Detail View so I can see the entire screen in the detail view?
B) How can I center my object if the guidelines are inherently off-center?
Thank you so much for you advice and input.
Are you using constraints to keep the various controls in place etc...?
If not try:
Select all elements in the UI of the detail view. Click on an empty spot somewhere in the View and press CMD + A.
Click on resolve auto layout issues at the bottom right of the Nib editor. (it's the right most icon)
Click on Clear Constraints
Click on resolve auto layout issues again, then Reset to Suggested Constraints
From here, tweak your constraints as per the UI you're working with i.e. iPhone, iPad and whatever orientation it's in etc...
I forgot to mention how I fixed the "too zoomed-in" problem.
In the storyboard controller, on the left navigator panel, within the file inspector, I simply unchecked "Use Size Classes" within the Interface Builder Document section. My view controller changed into a normal iPhone shape and everything finally fit into place.

Overlapping cells in static tableview built using storyboard

All,
I'm using the Xcode 6 beta to build an iOS8 project using storyboard and swift. In the storyboard, I've created a Table View Controller as my primary view when the application loads and have added a label to the first cell and a label to the second cell.
The table looks fine in the storyboard, but when I run the application, the cells overlap. This is a brand new project with no other changes made or code added.
You can see both the storyboard and the running application in the photo below. Any ideas on what could be driving this?
Additionally, when I try to add a button to one of the cells, I get a grey box that covers 90% of the view.
I think I've had this issue. Try making some Auto Layout connections from the label to the Content View of the cell, and from the table view (and its cells) to the containing view, to force the views to be the proper size.
The following worked for me.
Control-click and drag from your label to left side of the cell it's in. When the modal comes up, check the box for 'Leading Space to Container'.
Repeat the same Control-click and drag process for each side of the cell, selecting the relevant Auto Layout option when it appears.
(Optional) Try to Control-click and drag from your table view to the each side of the containing view (if there is one), and repeat the steps from above.
Hopefully this works for you.

Resources