Dynamically managing height of iscroll-wrapper in iscrollview.js - jquery-mobile

In my app. I am using iScrollview.js,to achieve smooth scrolling on touch screen devices.
iScrollview.js calculates height of iscroll-wrapper by this way :
$wrapper.height()+$pullDown.outerHeight()+$pullUp.outerHeight
In one view there is an accordion structure. When the accordion is expanded, I am unable to scroll properly due to the load-time height calculation of iscroll-wrapper.
I think this is due to the height of whole page being less than that of the accordion structure.
Can you please advise how to manage the height of iscroll-wrapper dynamically?

Related

UITableview to always take full display height

is there a way in which a UITableView can always take a fixed height and can scale the static cells i'm using to the remaining height? I'm trying to achieve that my tableview layout is always visible on different devices.
I think I understand what you're getting at with having the table view showing on all devices. Instead of setting a specific size I'd recommend using auto layout instead! You can read more here.

Horizontal full width scroll in flutter

Flutter Listview component uses scrollDirection to do horizontal scrolling.
How do i set the width of the individual items to window width and scroll one page at a time?
You may want to use a PageView instead of a ListView as it works just like you described. It fits better your purpose because you don't have to write all the logic to manage the threshold of the pages and it automatically allocates the entire screen width for each element.

UISlider causing horizontal scrolling

I have a simple screen, with a slider and a label positioned next to each other horizontally. I have embedded these inside a UIScrollView (I set this to fill the screen and used 'Add missing constraints'), because I will need vertical scrolling later down the line. I don't however, want horizontal scrolling. I have seen numerous posts on here and other sources about people wanting to disable horizontal scrolling, however I'm not sure that's what I want to do, I think I need to restrict the UISlider from causing the horizontal scrolling; I think it is trying to take up more width than the screen. I have added what I think are the necessary horizontal constraints:
Leading space to container for the UISlider
Horizontal spacing to the UILabel, and
Trailing space to container for the UILabel
But this still causes horizontal scrolling, and the UISlider's are the cause, they are taking up more room than I want, as seen below:
I have tried disabling horizontal scrolling in the code using a few techniques, one being:
func scrollViewDidScroll(scrollView: UIScrollView) {
if scrollView.contentOffset.x>0 {
scrollView.contentOffset.x = 0
}
}
but this does not seem to stop the horizontal scrolling.
Can anyone offer any suggestions?
Thanks in advance.
My suggestion is to never use Add missing constraints. It never does what you really want.
Here's the problem. You are laying out your UI on a ViewController in the Storyboard that is square. Apple did this to remind you that you need to be flexible in your design, but it doesn't match the size of any device. When you Add missing constraints, it uses the absolute dimensions of that square to create the constraints which are certainly wrong.
In your specific case, it is giving the slider a width that is too wide, which is why the slider goes off the right side of your screen.
Here's the trick about scroll views. If the contents inside of a scroll view are wider than the scroll view itself, then that content will scroll. The same applies vertically: if the contents inside of a scroll view are taller than the scroll view, then the contents will scroll.
In order to design this to work on all phones, you need to make sure that the contents of the scroll view are laid out correctly for each phone size. Which certainly means you don't want to use specific widths for both the label and the slider because you'll end up with the wrong width for some device, if not all of them.
The best way to do this is to:
Drag out the scroll view and add it to your ViewController. Add constraints to make sure it is properly sized on all phones, such as attaching it on all sides to its superview with a fixed distance.
Drag out a new UIView and drop it on the scroll view. Drag its edges until it exactly matches the size of the scroll view. This will be your content view. Pin all four edges of this content view to the scroll view with offsets of 0.
Here's a tricky bit. Even though you've pinned the content view to the scroll view, its size of free to grow because that is what allows it to be bigger than the scroll view itself and allow there to be content to scroll over. To keep your scroll view from scrolling horizontally, you need to make sure the content view has the same width as the scroll view on all devices. To do that, find the scroll view and the content view in the Document Outline to the left of the Storyboard. Control-drag from the content view to the scroll view and select Equal Widths from the pop-up.
You still haven't told your content view how tall it should be. For now, give it an explicit height constraint of 1000. That will be enough to scroll.
Now, add your label and slider to the content view. In addition to constraining them to each other and to the edges of the content view, you will need to give your label a width constraint. Then Auto Layout will have all of the information it needs to compute the width of your slider. Auto Layout knows how wide the content view is (which will be different on different devices), it knows how wide your label is, and how far everything is from everything else, so it will just stretch the slider to fill in the rest.
If you do all of this, you will have a UI that is properly sized for all devices in all orientations that scrolls vertically.
Just embed all view in your UIScrollView in a UIView, give it the required constraints then the slider and label will stay.
That worked for me just now.
UIScrollView is special when you want use AutoLayout with it, subviews can not be added directly, it needs a container view to constraint the contentSize of UIScrollView, Auto Layout Guide:Working with Scroll Views explains the detail reason, and you can find many solutions to solve UIScrollView's auto layout on Google, Such as this answer.
To be honest, it's confused and complicated to understand UIScrollView's auto layout, but if you overcome this, others auto layout question is easy to resolve.

Objective C - UI List Height

I need to build a fairly detailed home screen for a IOS app and I'm fairly new to IOS dev. it basically contains -
Styled button which displays important message count and a link to messages area.
a iCarousel slider which shows styled stat info
a tableview with several dynamic custom classes.
All of which are wrapped with a UIScrollView - my issue is I dont know a method of working out the compiled height of the UIScrollview - Is it possible to give it an autoheight? If not how do I go about generating a height and applying it to the UIView?
Is it possible to give it an autoheight? If not how do I go about
generating a height and applying it to the UIView?
Yes, you can use it with Auto Layout. See the section "Pure Auto Layout Approach" at UIScrollView And Autolayout. UITableView is also a scroll view, so you will have to add a height constraint to it - the height can be calculated with sizeThatFits:.

Xcode 5 Auto Layout - Embedded Tables

I have a UIScrollView with several UITableViews embedded in it. I want to allow each table to expand its height as much as is needed to display all of its cells. The scroll view's frame takes up the whole screen, so its contentSize.height need to expand to fit the biggest table (which I think is the default behavior, but I mention it just in case I'm incorrect). Can this all be done on my storyboard? Or if I will need to add code to do it, I found this tutorial, but it's for iOS 6 - has any of the code for this constraint stuff changed for iOS 7?
If you know in advance how much room each table takes up you can do it purely in your storyboard, but because each UITableView is also a scrollview the default behavior of a UITableView is to fill the assigned size with content and scroll if there is overflow.
If you do not know the height of the tables at design time, you will need to set them at run time. See Autolayout a UIScrollView to fit content including subviews and grouped tables for an example, the short answer is to add a height constraint to your table, drag it into your controller as an outlet, and then set the height when you know it.
It can be done both ways.Manually moving UI elements through code(mentioning locations) and overriding it in did rotate or through mentioning constraints in auto layout.
This link http://www.doubleencore.com/2013/09/auto-layout-updates-in-ios-7/ provides details of ios7 auto layout .

Resources