UserGuide

iOS Scrollable Area

From Xojo Documentation

A scrollable area allows users to scroll a container that otherwise has more content than can fit in the visible area. When users interacts with content in the scrollable area, horizontal or vertical scroll indicators briefly display to show users that they can scroll around to reveal more content. Other than the transient scroll indicators, a scrollable area has no visual appearance.

Refer to iOSScrollableArea in the Language Reference for the full list of events, properties and methods.

Properties

Content

This is a Container Control to display in the scrollable area. If the container has more content than can fit in the view, the user will be able to scroll to see it.

Usage

To use a scrollable area, drag the control from the Library to the layout. In the Inspector choose an existing Container Control for the Content property. Use the Content property to get a reference to the Container Control at runtime so that you can call methods on it (or access its controls). For example:

// Get reference to container control
Dim cc As MyContainer
cc = MyContainer(ScrollableArea1.Content) // cast to MyContainer

// Now you can call methods on it
cc.UpdateData

There may be situations where you need to dynamically alter the size of the Container Control at run-time, perhaps because the size of its content has increased. You can do this by adding a Height constraint to the Content area like this:

Dim newHeight As Integer = 2000

Dim contentConstraint As iOSLayoutConstraint
contentConstraint = New iOSLayoutConstraint(ScrollableArea1.Content, _
iOSLayoutConstraint.AttributeTypes.Height, _
iOSLayoutConstraint.RelationTypes.Equal, _
Nil, _
iOSLayoutConstraint.AttributeTypes.None, _
1, _
newHeight)

Self.AddConstraint(contentConstraint)

Example Projects

  • Examples/iOS/Controls/ScrollableArea

See Also

iOSScrollableArea class; UserGuide:iOS Container Control, UserGuide:iOS UI topics