I want the user to be able to select a single row in a UITableView and then have that row show the Checkmark accessory. First to check how it looks in the UI, I added the checkmark through the XCode Interface Designer, like this;
Ran it on the iPhone X Simulator and it works as expected.
But when I run it on the iPad Pro (12.9 inch) (2nd generation) Simulator it doesn't show up.
So I thought that maybe the constraints were the issue, so I tried writing the widths of all the views that could be the problem to the console and they all returned 1024 so that is correct.
When I try setting the checkmark through code I have the same problem.
Am I missing something here?
EDIT:
Screenshot with red borders on the cells.
Your issue is definitely about constraints and Auto Layout.
You should set constraints to superView for checkmark : trailing/top/bottom
Horizontal spacing between the UILabel and the Checkmark.
And Edit this last constraint to make it "Greater or equal" so that it will eventually grow with bigger screen.
You will also want to change your content hugging priority.
Simpler solution : You could also use UIStackView in order to proportionally align your label and your checkmark regardless of the screen resolution.
Related
Trying to achieve UIStackView with 2 labels for iPhone and 3 labels for iPad using size classes.
View hierarchy
Default size class
[UIStackView]
[UILabel 1] [UILabel2]
[UIStackView]
RxR size class
[UIStackView]
[UILabel 1] [UILabel2] [UILabel3]
[UIStackView]
It looks exactly as expected in Storyboard as you can see in the above screenshots but on simulator iPad view is messed up.
iPhone Output (okay)
iPad Portrait Output (messed up)
iPad Landscape Output (messed up)
What's happening in iPad?? Is it a bug or I'm missing something?
Thanks.
I have created a sample project.
Follow below steps to achieve your requirements :
Drag one horizontal Stackview in to your interface builder
set it's constraints like : top,leading, =trailing and fixed height
Drag and drop three labels in to it and select all together and set one constraint : Equal width
now select second or middle label and from attribute inspector click on + button beside installed and select Regular for both width and height. It will add regular,regular variation and uncheck the checkbox for that R,R variation. Refer below screen shot for better understanding,
And you are done! now you your center label will not show in iPad and every label will be displayed in iPhone!
See below result screenshot of iphone and ipad in my case!
iPhone :
iPad :
Update :
If you want two to hide label in iPhone and show in iPad then add one more variation : Compact Width Regular Height for middle label and uncheck the checkbox to uninstall. Refer below screenshot,
It seems you are hiding one of the labels on iPhone using the "installed" checkbox in Interface Builder. Using the "hidden" checkbox instead seems to solve the problem. Which I guess is a bug.
I have designed simple one page design for universal application. so I had faced issue while checking the 4 inch devices its working fine. other than 5.5 to above devices its not looking good.
View(MAINVIEW)
ScrollView
View
Label
..
..
above I have mentioned the structure of the page.below I have mentioned screen shots.
above Screen shots image I have designed. with all constraints.
after that I have checked the preview of the page design.
Iphone 4-inch its showing fine. but Iphone 5.5 its showing in bottom not filled whole page view.
It looks like then you have set the height constraint for ScrollView or view. If you did this then remove that height constant and set the bottom constraint which should have 0 constant value to its superview.
When I run my Swift app in an iPhone 6s simulator, the text field seems to be getting vertically stretched. The storyboard can be seen below:
The app running in the simulator can be seen here:
I am not sure how to prevent this. I would like the bottom text field border to be closer to the placeholder text. Manually changing the height of the text field in the storyboard has not worked. I have constraints from each side of the text field to the respective side of the parent view. The storyboards are set to iPhone 6s and the simulator is set to iPhone 6s, surely the storyboard content should look almost identical in the simulator. Can anybody offer any assistance on this?
Remove the bottom constraint of the textfield! It is causing the textfield to increase height when view gets bigger.
To increase the size of the textfield with the size of device, you should add one more constraint: Aspect Ratio.
There must be problem with the constraint. First set your textField contraint to center vertically, center horizontally or remove one of the constraint upper or lower one.
If you look at the screenshot, showing a list of US states, "WV" is not the last row, there are two more rows after: "WI" and "WY" which extend beyond the bottom of the layout. This used to work with Xcode4/iOS6 regardless of whether or not you were in 3.5-inch or 4-inch. Now this only seems to work for 4-inch but not 3.5-inch.
Does anyone know how to get the height behaving correctly for Retina 3.5-inch?
The orange background in the storyboard screenshot below is the View background color.
You need to use the buttons in the lower right-hand side of the interface builder. Specifically, you can use the "Pin" button to create constraints to the top/bottom and other gui objects.
Constraints in Xcode4 used to auto-create if you dragged an object to the edge of the screen but not anymore in Xcode5 which is why I was confused.
On an iPhone 4 (or any iPhone/iPod device without the 16:9 iPhone 5 resolution) my popover looks great; not stretched at all and exactly as I intended.
However, on an iPhone 5 the popover is stretched:
And I can only assume it's because of a constraint with Auto Layout, but I can't quite figure out what is causing it.
When I select the UIView that contains all the controls in the window (and what appears to be being stretched) in Interface Builder these are the constraints it has on it (again, apologies for the height of the image, it has a lot of subviews):
I thought it was Top Space to: Superview Equals: 103 but I cannot delete that. I promote it to a user constraint, then delete it and it just reappears.
What am I doing wrong here?
In Xcode you can't delete a constraint unless there is enough constraints remaining in order for Xcode to determine the layout in Storyboard or IB, usually at minimum 2 constraint vertically/horizontally. So you will need to add a height constraint (2nd from the top) first before deleting the top space constraint:
This will give you a fixed height constraint that you want in the first place.