I tried to set ImageView as a child of ScrollView on the Objective-C storyboard and autolayout as ImageView, but it didn't apply properly no matter how much I tried, and the ImageView became strange (I want to set up space on top, bottom, left, right).What should I do in this case?
objective-c xcode scrollview uiimage
Does "On the Objective-C storyboard" mean that you want to set up Auto Layout in the program (NSLayoutConstraint)?Or do you want to use the mouse on the Storyboard?
Anyway, I'd like to keep this as an overview of Auto Layout.
The basic idea of Auto Layout is to impose constraints that uniquely determine the location and size of objects.There is no better limit than a good limit, but the point is that constraints that can be multiple possibilities result in errors.
The most frequently used constraints in practice are shown below.
Determining the horizontal (X-coordinate) and vertical (Y-coordinate) spacing of nearby objects and determining the width and height of the object uniquely determines the location and size of the object.
However, if you look at the objects in the scroll view, the location of the objects is not uniquely determined.This is because the content size in the scroll view is indefinite.If you want the program to place objects in a scroll view without Auto Layout, you must first place the CGSize
value in the UIScrollView
property contentSize
and then place the Subview
.
When Auto Layout places objects in a scroll view, it is not uniquely determined until you determine the location and size of the objects, as well as the content size.Specifically, the constraints are as shown in the picture below.
From the previous picture, there are two additional restrictions.Only by setting constraints on all edges of the content area in the scroll view, plus the width and height of the plus object, and a total of six constraints can a unique position and size be determined.At the same time, content space size has been determined.
617 Uncaught (inpromise) Error on Electron: An object could not be cloned
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
581 PHP ssh2_scp_send fails to send files as intended
914 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.