autolayout constraint not working - iphone

I want to implement scrollview (Horizontal scroll)with paging and one of the page also contains another scrollview (Vertical scrollview) but elements in scrollview not follow autolayout constraints.Please suggest me way to implement it.
Here also attached image what i want to implement it.
Thanks
Nirav Zalavadia

Embed contents in the scrollview to a UIView. Set constraints to UIView withrespect to scrollview and set constraints to elements with respect to UIView.
While setting the constraints for UIScrollview and its container UIView, check whether the content size is setting correctly. Otherwise there is some problem with the constraints you have added.

Related

Image view crush stackview constraints in swift?

I have some issue about my stackview contraints or imageview constraints ı dont know actually.Probably both . This is my stackview constraints stackViewConst and this my imageview constraints imaviewConstraints . When ı try to run ı expect everything looks awesome however unfortunately ı get this screen screen my stackview is lost.How ı can figure out this help me
Answer: add stackview height constraint
(or add stack view content resistence and content hugging priorities higher than those of your UIImageView)
Explanation:
Since you are using storyboard's Interface builder (IB) for creating constraints, as opposed to pure code. The IB uses feature of auto-constraints, which basically means that the IB can figure itself the layout and constraints based on what is displayed in your storyboard. The UIStackView is using some dynamic resizing (so that elements within stackview are properly layed out) and it is always good idea to give it size constraints, or at least size constraints to elements inside UIStackView , otherwise it might decide that every element has size of CGSize(height:0,width:0) You can also make priorities of your UIStackView higher than those of your UIImageView so that IB would prioritize the size of your stackview's constraints to those of your imageView

Keeping an image view out of scrollview scope. Xcode, Swift

Please take a look at an image below
There is a scroll view. But I don't want an imageView(topBar) move. How can I keep an image view out of scrollview scope? (I mean fixed topBar, no move) With a constraint? And managing the constraint from code behind during the scroll?
Move the top bar image so that it isn't in the scrollview. It's parent should be the View0 Outlet, then you can constrain it however you want without it moving in then scrollview.
Using a stackView with vertical setting and free form. In this case, you can lock the height of topBar.

StackedView inside ScrollView in Xcode 8 / Swift 3

I'm trying to arrange stacked views so I can set out the UI of my app to look neat and tidy.
The only problem I'm having at the minute is getting it set up so I can see it!
At the minute, it looks like this on Main.storyboard and it's annoying me:
Storyboard view
My constraints are currently set up as follows:
Constraints (edited)
Where am I going wrong?
Your UIScrollView needs to know its content's width. Since it can scroll both horizontally and vertically, it does not act like a UIView on interface builder.
One thing you can do is adding a hidden UIView in UIScrollView with 0 height and |-[WidthView]-| constraints (leading and trailing to its superview - UIScrollView). And then you should add WidthView.width = UIScrollView.superView.width constraint.
This makes sure that your UIScrollView's contentView's width is always equals yo UIScrollView's superView's width.
Your view hierarchy should look like this:

Making an Expanding Scrollview

I'm currently making a drawing application in Swift, but I wanted the page to be able to expand if the user wanted more room. I figured that I would use a UIScrollView to scroll around the canvas, but I wanted it to expand whenever the user went to the edge of the page, and for the UIImageView that I am drawing on to expand with it. Does anyone know how I would go about doing this?
Thanks!
In storyboard, drag a UIView into your UIScrollView then constrain that view to all sides of the scroll view. Then set the width to whichever value you would like (I would recommend to control drag from your view to the root view of the view controller and select equal widths), then give it a height constraint. Next, you need to connect an IBOutlet to your view controller code for the height constraint you set on the content view inside the scroll view. When you need to extend the page, add to the value of the height constraint and call layoutIfNeeded() on the scroll view.

How to scroll a simple UIView (not uitableview) in iphone?

I have added some uitextview in my uiviewcontroller.But some of the textViews are not seen as view is small compared to the number of textViews. So I want scroll it, so that i can see the other textViews also. One more thing-- when i want to type something in the lower textView then it hides because of the iphone keyboard.If somebody knows about it, please give me with the solution.Thanks a lot.
Add UIScrollView in self.view. Now add all subviews to UIScrollView.
Provide contentSize of UIScrollView in width and height.
if heigth > 460 it will scroll vertically
if weight > 320 it will scroll horizontally
If any condition doesnot matches then u will not be able to scroll
You simply have to use UIScrollView.Instead of adding all of your subviews(in your case multiple UITextViews) in the main view, just add a srollView in your view and then add all subviews in that scrollView.UIView doesn't have the property to scroll.And don't forget to change the contentSize property of scrollView.
You must implement a UIScrollView. This is a fundamental class when it comes to iPhone development (and just Apple development in general) and it should be mastered before you continue onto more advanced topics. Here is the documentation for the class :
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html