Im using a UItableview with auto height, i have 3 labels : label, sublabel and price. on top of the table i have a view attached to the bottom of screen. when scrolling the table down, it auto hides, when coming back up it shows again (kinda mimics safari functionality..) , heres comes the glitch. if i pin the sublabel to the bottom. ( as everybody knows if you are using cell auto height you have to.. otherwise the text will just mess up and the height of the cell won't change... . my bottom bar view will hide when scrolling , but when scrolling some more it glitches and pops back out for half a second, this only happens only when time, that first time the view appears...
im kind of stuck on this, i cannot unpin the sublabel, cause it will mess the cell height, etc. and i cannot have this glitch on messing up either... is there another way to make the auto height on cell work ?
This is the basic layout. as you can see.. normal table view a a view on top which fixes to the bottom.
constraints.
Everything has their constraints for good. In this picture i deleted the bottom constraint and the top constraint to Label of the sublabel (i decided just not to display the sublabel text while i figure this bug out..) Thats when the bug happen (if enabled). In this in table im using auto/ dynamic height. the label and the sublabel are settled lines to 0, wordwrap by word and they have their constraints ok. i have a mechanism that when user scrolls down. the Bottom bar hides down, if the user comes back to top of the table, the bottom bar shows up. so the thing is, for the uitable cell to auto height u really need 2 must constraints. one top, one bottom. if i eliminate the bottom constraints like in the pic. the bug from the bottom bar flicking disappears but i don't get my table cell auto weighted so the text will mess up... if enabled then i get the flicking bug one time, that first load. then it works normally
Related
Hi I want to put CollectionView in fullScreen
So I set it's constraint all top, buttom, left, right zero with SafeArea
But in iPhone 11, When I put many Items, CollectionView Cover the SafeArea with scroll
And I can't see last Item fully
I can see the Item when I scroll, but it bounce up immediately
When I set HeightConstraint with Constant, same height with SafeArea, It looks perfect
So I guess the reason of problem is that Height of SafeArea be changed when CollectionView require Scroll
Any Suggestion for this?
If I can, I want to solve it with StroyBoard
First screen is Auto Layout that I set on Storyboard
And Second One is current Work
I can't see the bottom of Last Cell , I can see if I scroll down, But It Bounce up like that
In your view hierarchy, I noticed a header view is residing for your collection view. Have your tried defining it's height using referenceSizeForHeaderInSection method? You will find that method in collectionViewLayout. Here's reference link :- https://developer.apple.com/documentation/uikit/uicollectionviewdelegateflowlayout/1617702-collectionview
Currently I'm displaying two labels and view on a tableview contentview cell on my app. Without constraints, the labels display correctly on the device. However, when I add constraints to the labels in the storyboard, they always align to the left. I'm currently using top, bottom, leading/trailing (left & right), and have in other attempts also set height and width.
New Constraints storyboard:
However, when I run it on any device, it always looks like this:
Actual view:
I'm wondering why this keeps happening. I want to avoid doing constraints programmatically in this app to show I can use storyboard, but this one problem has stumped me. I've tried reading up as much as I can, but I just can't get it to work. Any idea how to get it to look like the first picture, all the time when, adding constraints?
So I tried embedding my label (that has all the text) and buttons in a scrollView to perhaps be able to scroll down to them, but when I do that, everything just disappears.
my storyboard
my preview
Just added some pictures as requested (thanks).
As for adding the scrollView (which may not be the optimal solution), I just selected all 4 buttons and the label, then selected "embed in scrollView". This led to a completely blank screen in preview.
It sounds like you need to fix the bottom constraints of your scrollview, so that the scrollview's frame does not extend past the bottom of the screen. You can then set constraints on the scrollView's content size to allow the user to scroll.
From the storyboard image you posted, it looks like there isn't a bottom constraint. Select the scrollview in the storyboard, click the pin icon, and put in a number in for the bottom constraint (e.g. 0).
I have a weird behavior when I use scrollView.
As you can see in the picture bellow the button called "Back" has a bottom space constraint with value 0. But we can see is not even near to the bottom of the scroll view.
I already set the scrollview to have equals width and height of the superView and top,bottom,trailing and leading space with 0 value.
How can I fix this? I want the Back button still inside of the scrollview and put it at the bottom of the view.
Update
I have the code here https://github.com/rchampa/NDParallaxIntroView and the xib is called PageB.xib
Ricardo: you've added two constraint regarding manage y position of Validate Code button where your top constraint stop to move Validate Code button towards the bottom. So please remove top constraint of Validate Code only add bottom constraint.
you need to manage all constraint like your scrollview content view height will be equal to height. Please increase some top constraint from top.
So, if I understand correctly, the problem you are running into is that your back button is unable to be positioned based on the bottom of the scroll view.
A scroll has two sets of constraints in a storyboard, one that defines the size of the scroll view, and the other that defines the content size. The top, left, bottom, right to superview constraints on the scroll view will define the size.
The part that is causing your problem is that the content size is defined by the subviews inside the scroll view. So the button cannot be placed relative to the bottom of the scroll view since the scroll view doesn't know how large its content size is. All of the subviews of a scroll view must be placed in relation to each other.
So, create constraints for your logo, text fields, and all the buttons in relation to each other. Then create constraints from the outer most subviews to the scroll view.
In your example, you would constraints from the logo to the text field, 1st text field to 2nd text field, then 2nd text flied to the label, label to the "Send email..." button, and finally "Send email..." to the "Validate Code". For the "Back" button, it would need a left align with the text fields and then a center align with the "Validate Code" button. Create a top constraint from the logo to the scroll view. Then have leading and trailing constraints from one of the text fields to the scroll view. Finally, create a bottom constraint from either the "Back" or "Validate Code" buttons to the scroll view. You will also need some alignment constraints (logo center to the text field is an example of one). After that is all setup, your view will be fully defined for the content size of the scroll view.
If I understand you, my new question is: how can I make the subviews
make the height of scroll fit 100% screen device height? Is there a
way to define weights like Android? I don't know how achieve this
since the canvas is 600*600 which is different to every device.
Response would be too long for a comment:
So you wouldn't use a scroll view for that. A scroll view is specifically for containing content that will not fit on the screen (so the user can scroll to reach the new content).
The simplest solution is to add a regular view that has TopLeftBottomRight 0 distance constraints (so it is the max height and width of the screen) and setup the view like you have here to position the bottom in the bottom left all the time.
There is also a weight system, I can explain that if you want, but it wouldn't be required thus far.
I feel like your next response will be something like "what if I want it to scroll when its too small for the current screen?". The only way I know of doing that in encapsulating all your interface into a single UIView, and changing its sized in the viewDidLoad/viewDidAppear based on the size of the scroll view. Something like this:
func viewDidLoad() {
super.viewDidLoad()
containerViewHeightConstraint.constant = scrollView.frame.size.height
containerViewWidthConstraint.constant = scrollView.frame.size.width
}
Similar to Mail.app where you can scroll the cells side to side, I want to be able to do it in my app using Storyboards and UIScrollView with my UITableViewCell.
I add some buttons to the contentView of my cell, and then UIScrollView with an embedded UIView on top of that to contain the main portion of the cell. I then add a label to that.
I understand that scroll views in Storyboard work by specifying constraints to show what the contentSize of the scroll view should be.
So I position the UIView in the UIScrollView to be the same width and height of the scroll view, but give it a trailing constraint of say 50pt to allow the scroll view to scroll. When I run it I can then move the cell to the left to reveal the buttons.
But to get it work in the other direction I have no idea. If I add a leading constraint it actually moves the cell to begin with away from the left, offsetting the cell to begin with when it should be left to the user to scroll it. It works fine other than initially being pushed over.
I created a sample project showing it here: http://cl.ly/2i3m1W2T0i3C
Like I said I just can't seem to figure out how to get it to scroll in both directions.
Try setting the contentView of the scrollView with width higher than the scrollView itself.
Something like:
Assuming your scrollView.frame is (0,0,100,100)
[scrollView setContentSize:CGSizeMake(300,100)];
place your table view, let a part of your view out of the screen and check that case: