Class

MobileHTMLViewer


Description

A scrollable HTML viewer control.

Events

Name

Parameters

Returns

Closing

Opening

Property descriptions


MobileHTMLViewer.AccessibilityHint

AccessibilityHint As String

The accessibility hint is a longer description that is read aloud when VoiceOver is enabled.

Me.AccessibilityHint = "Click to calculate the value and display the next screen."

MobileHTMLViewer.AccessibilityLabel

AccessibilityLabel As String

The accessibility label of of a control is a short name that is read aloud when VoiceOver is enabled.

Me.AccessibilityLabel = "Calculate the value."

MobileHTMLViewer.ControlCount

ControlCount As Integer

The number of child controls in the control.

This property is read-only.


MobileHTMLViewer.Enabled

Enabled As Boolean

Indicates whether the control is enabled or disabled.

Disable the button:

Button1.Enabled = False

MobileHTMLViewer.Height

Height As Double

The height of the control.

This property is read-only.


MobileHTMLViewer.Left

Left As Double

The left position of the control.

This property is read-only.


MobileHTMLViewer.Name

Name As String

The name of the control.


MobileHTMLViewer.Parent

Parent As MobileUIControl

The parent (sometimes called a “Super”) class of the control.

This property is read-only.


MobileHTMLViewer.TintColor

TintColor As ColorGroup

Changes a control’s tint color.

On iOS, the following controls support TintColor:

Enum

Description

ProgressBar

The area indicating the value of the control will be drawn in the TintColor.

Slider

The area indicating the value of the control will be drawn in the TintColor.

TextArea

The cursor and text highlight color will be drawn in the TintColor.

TextField

The cursor and text highlight color will be drawn in the TintColor.


MobileHTMLViewer.Top

Top As Double

The top position of the control.

This property is read-only.


MobileHTMLViewer.Visible

Visible As Boolean

Indicates whether the control is visible.

Make a button invisible:

Button1.Visible = False

MobileHTMLViewer.Width

Width As Double

The width of the control.

This property is read-only.

Method descriptions


MobileHTMLViewer.AddConstraint

AddConstraint(constraint As iOSLayoutConstraint)

Adds a constraint to the control.

This constraint is used by child controls that have been added to this control.


MobileHTMLViewer.AddControl

AddControl(child As MobileUIControl)

Adds a child control to the control.


MobileHTMLViewer.ClearFocus

ClearFocus

Removes the focus from the control.

TextField1.ClearFocus

MobileHTMLViewer.ControlAt

ControlAt(index As Integer) As MobileUIControl

Gets the child control at the specified index.


MobileHTMLViewer.Controls

Controls As Iterable

Allows you to iterate through all the controls that have been added to this control.


MobileHTMLViewer.Handle

Handle As Ptr

The a handle to the underlying native OS control.


MobileHTMLViewer.LoadPage

LoadPage(file As FolderItem)

Displays the HTML passed.


MobileHTMLViewer.LoadPage

LoadPage(HTML As String)

Displays the HTML passed.

iOS sandboxing of the app and the HTML Viewer can prevent the HTML Viewer from seeing files that are in the app’s Documents folder. This code can be used to provide access to files in the Documents folder:

Declare Function NSClassFromString Lib "Foundation.framework" (clsName As CFStringRef) As ptr
Declare Function URLWithString Lib "Foundation.framework" Selector "URLWithString:" ( id As Ptr, URLString As CFStringRef ) As Ptr

Declare Sub loadFileURL Lib "UIKit.framework" Selector "loadFileURL:allowingReadAccessToURL:" (obj As Ptr, url As Ptr, readAccessURL As Ptr)

// htmlFile is a FolderItem from SpecialFolder.Documents
Var nsURL As Ptr = URLWithString(NSClassFromString("NSURL"), htmlFile.URLPath)
Var readURL As Ptr = URLWithString(NSClassFromString("NSURL"), htmlFile.parent.URLPath)

loadFileURL(HTMLViewer1.Handle, nsURL, readURL) // Display the contents in an MobileHTMLViewer

MobileHTMLViewer.LoadURL

LoadURL(URL As String)

Displays the specified URL.

Be sure to include the appropriate prefix, such as “https://”.

To load HTML from a file on the device or to load HTML as a String directly, use LoadPage.

Display wikipedia:

HTMLViewer1.LoadURL("https://www.wikipedia.org")

MobileHTMLViewer.Refresh

Refresh

Marks the control so that it will be redrawn during the next event loop.

Call Refresh to force a Canvas to redraw itself:

Canvas1.Refresh

MobileHTMLViewer.RemoveConstraint

RemoveConstraint(constraint As iOSLayoutConstraint)

Removes a constraint from the control.


MobileHTMLViewer.RemoveControl

RemoveControl(child As MobileUIControl)

Removes the control from the control.


MobileHTMLViewer.SetFocus

SetFocus

Sets the focus to the control.

TextField1.SetFocus

Event descriptions


MobileHTMLViewer.Closing

Closing

Called when the control’s layout is closing.


MobileHTMLViewer.Opening

Opening

Called when the control’s layout is opening.

This is where you typically put initialization code.

This example in the Opening event of a label sets its text to “Hello”:

Me.Text = "Hello"

Notes

iOS requires the use of secure “https” connections or the page will not display.

Compatibility

Mobile projects on all supported mobile operating systems.

See also

MobileUIControl parent class; URLConnection class