One item (button) is always smaller in iOS UIStackView - ios

Using Xcode 7.2 [using swift but that shouldn't matter for this] ... I have put two buttons, 'Done' and 'Add', into a UIStackView as such:
But at runtime the 'Add' button is always smaller as:
I have tried every combination of fill and spacing on the StackView, etc. I have tried setting widths and heights but the 'Add' button is always smaller. I have the same problem in another UIStackView (also horizontal) where the Add button is first.
The two buttons shown have the same natural pixel size and are multi-sized. For example here is the setting for 'Add':
I tried deleting it from Xcode and adding it back. Is there some factor that I am missing? This is driving me nuts.
One hint that might help is that I think that when I first added it with this name, it actually was smaller, but since then I have deleted it and re-included it in the project. Perhaps there is some 'memory' there that I can't find?

Ack, thanks so much for the answers and comments. But the problem was that the '#2x' Add image was misscaled. Fixing that fixed the problem; only took me days to find it as I guess I checked and rechecked the 1x and 3x sizes but never the 2x one. Sorry to waste your collective time.
I am still not very comfortable with all the layout settings and have 6 storyboards in the app that have around 60 layout warnings, but am getting there.

Related

Stack button fail

Swift 2.2 Xcode 7.3.1. iOS 9. Storyboard. I have 7 rows of four labels across. I was intending to select each row to place it in a stack. Saw this technique in Hagerty's iTunes U (Stanford). Each time I select a row and press the button to add the four across to a stack, it makes these huge rectangles... They have a width of 127,000,000. I keep trying different things, adding all suggested constraints, getting rid of all contstraints, etc.
Any idea what I am doing wrong? TIA
Sorry, I'm apparently not allowed to add images as yet here... The rectangles on the View Controller are all UILabels. When I select a row of them and press the Stack button, next to pin, etc., it appears to make one wide rectangle, all 4 on top of each other, this last time is was 27,216,026 pixels across. I think the comment about not using "suggested" constraints is probably a clue... there certainly seem to be more than necessary. There are also some where I tried to delete a constraint where the constraint item appears to be dimmed. There are one or two where the dimmed one, and an exact copy of the dimmed are both there...
There are no images on the view... the only button is up top, a "Back" button.
Someone gave me the clue. It turns out that there are some bugs in the constraints setup, especially when using "suggested" constraints. I deleted all the constraints, then added just the minimum needed, made sure they were all perfect, and I got one row to work properly. Now I can do the others.
After I do this enough times I am sure it will make sense, there is probably one constraint mechanism that doesn't work as it should - an Xcode bug. One adds size constraints both in the size inspector, and potentially the constraint mechanism, and sometimes they do not match. Those things have to be fuddled with until they do... and then Stacking works...

StackView within StackView - Overlapped Views

I have been trying to put together a view using Stack Views. The layout looks acceptable within Xcode but the 2nd, 3rd and 4th rows seem to overlap a small area when reviewed in the simulator.
There are some autolayout warnings and if I autofix one issue (Fix misplacement > Update frames) others appear. I basically end up toggling between placement issues. I must be fixing them in the wrong way.
Is there anything obviously wrong?
Why are these views overlapping each other?
What strategy should I use to fix the misplacement issues?

Universal Storyboard Preview - doesn't seem to work properly?

i have created a Storyboard where i create universal views for all iphones in portrait form. Simple views work just great, but as soon as you add different views and sub element something goes wrong. Can someone give me some tips what i am doing wrong?
I will be thankful for every kind of tips/advises how to get rid of this annoying view...
Have a nice sunday!
I found out the solution, the problem is that you can set all the measures in percent. But for to count all the sizes, XCode needs minimum 1 measure for width & height. If it gets the size of single element in your design, it can calculate all other sizes.

iOS 7: Misplaced View Frame for "Label - Label" will be different at run time

I just finished an app on iOS 6 and bought a developer account a week ago so haven't had much time playing with the iOS 7 SDK. Just downloaded the Golden Master version and trying to upgrade my app to be compatible with iOS 7.
I received a lot of warnings saying
Misplaced View Frame for "Label - Label" will be different at run time.
and I am unable to run the program. The project contains tableview and its is parsing and displaying XML feed from an RSS.
How to fix this issue?
The accepted answer will fix the problem, but that's not a good solution because it'll remove all your constraints. If you have spent hours on the constraints then don't do that.
If you click the triangle next to the warning you can get the explanation of what is misplaced. Then you can just move the frame to where it's supposed to be. For example:
In this case I just moved my Text View's y position to 94 and the warning will go away. This is because one of my constraints will force the view to be somewhere else when the app is running, but the position is different than where it currently is in the storyboard.
Another way to move the frame to the right position is to click on the warning next to the View Controller name in your storyboard, and then click on the yellow warning sign, and click update frame.
These two methods are not destructive and will not remove your constraints. If anything it'll show that you may need to do minor readjustments in your constraints.
I had the same issue and I get below response form Apple:
You need to update the constraints to match the frames of these views.
I did the following:
Editor -> Resolve Auto-Layout Issues -> Clear all constraints in ** view controller
then I reordered my objects again in the view.
PS: Try Enrico's solution first.
I had the same issue what you need to is , update the constraints or update the frame.
On storyboard you have a small tool bar as shown in below image.
Please see the meaning:-
You can either choose "Update Frames" or "Update Constraints" and Use "Reset to Suggested Constraints".
This will resolve the issue regarding misplaced View.
Don’t drag and drop views to make adjustments to layout. Edit the applicable constraints instead.
Please , let me know if you not clear.
If you are having troubles finding the Update Frames in xCode it can be done like so:
None of the answers work in all cases. As of recent version of Xcode, using a UISearchBar, enabling scoping field enabled in IB makes the search field appear double height (but doesn't show a the scoping bar beneath it). Whether or not you add a height constraint (of any height) to the search field, you'll get the warning that it is a misplaced view that will be 88 H at runtime but is 44 H in IB. Updating the frames (any or all frames) doesn't resolve it. Seems like a bug in IB.

Storyboard layout not correct on iPad 2

I am trying to lay out objects on a Storyboard using the interface builder yet when I run the app on an iPad2, the layout is being messed up and objects are not appearing where they should. All the objects are there but they are being moved horizontally and not the same number of pixels! For instance, I have two ImageViews overlayed on one another (one is 100x100 and one is 75x75 centred within) but when the app is run on the iPad, they are both being moved horizontally across the screen by different distances!
I'd like to add screenshots but unfortunately I can't for privacy reasons.
I know it's vague but does anyone have any ideas on where to start looking to fix this?
Thanks.
I had this problem too when I was first making an iPad app.
Try fiddling with some of the 'struts & springs' of the interface elements in the storyboard. To do this, select some of the interface elements, then on the right panel go to the size inspector and try some things with the 'Autosizing' rectangle.
Hope it helps!

Resources