beetlebug

ztk::ios

Makes the views of UIKit from a script: screens, lists, a navigation stack, tabs, alerts, and controls.

Synopsis

ztk::ios::app root ?OBJECT?
ztk::ios::alert ?OPTION VALUE ...?
ztk::ios::photos ?OPTION VALUE ...?
ztk::ios::CLASS new ?ARG ...?
$OBJECT METHOD ?ARG ...?

Arguments

Name Type Default Meaning
ztk::ios::app command Shows a screen, a navigation stack, or a tab screen in place of the Tk window.
ztk::ios::alert command Shows an alert or an action sheet, and gives its object.
ztk::ios::photos command Shows the photo picker, and gives copies of the picked photos and videos.
ztk::ios::NavigationStack class A stack of screens with a navigation bar (UINavigationController).
ztk::ios::TabScreen class One of its tabs at a time, with a tab bar (UITabBarController).
ztk::ios::Screen class A page with a column of views (UIViewController).
ztk::ios::ListScreen class A page of rows in sections (UITableView).
ztk::ios::TkScreen class The Tk window of the app as a screen of a navigation stack or a tab screen.
ztk::ios::Label class A text (UILabel).
ztk::ios::Button class A button (UIButton).
ztk::ios::Switch class An on and off switch (UISwitch).
ztk::ios::DatePicker class A picker of a date, a time, or both (UIDatePicker).
ztk::ios::TextField class A field of one line of text (UITextField).
ztk::ios::TextView class A text of many lines (UITextView).
ztk::ios::Stack class A row or a column of views (UIStackView).
configure ?OPTION VALUE ...? method Sets options. With one option, gives {OPTION DEFAULT VALUE}. With no argument, gives that list for each option. Each object but an alert has it.
cget OPTION method Gives the value of an option. For the text of a label, a text field, or a button, the title of a screen, and the state of a switch, it reads the value from UIKit.
destroy method Frees the object and its view.
-hidden boolean 0 Label, button, switch, text field, text view, stack: 1 hides the view.
-accessibilityLabel text empty Label, button, switch, text field, text view, stack: the name that VoiceOver reads.
-accessibilityHint text empty Label, button, switch, text field, text view, stack: what the view does, read by VoiceOver after the label.

Each object is a TclOO object. A -command script runs at the global level with the object appended. An error in a script or in a method of a data source goes to bgerror.

Return value

new gives the name of the new object. configure with values, and destroy, give an empty string.

Errors

Error When
unknown option "-X": must be ... The class has no such option. The message lists the options of the class.
value for "-X" missing configure has an option with no value.
expected boolean value but got "X" A boolean option has another value.
invalid command name "ztk::ios::..." The program is not an app on iOS.

Platforms

Platform Works
Windows No
macOS No
Linux, Wayland No
Linux, X11 No
Web No
iOS Yes
Android No: ztk::android
Headless No: the namespace does not exist.

Example

if {[namespace exists ztk::ios]} {
    set screen [ztk::ios::Screen new -title Hello]
    $screen add label -text "A screen of iOS."
    $screen add button -text "Tap me" -command {puts tapped}
    ztk::ios::app root [ztk::ios::NavigationStack new $screen]
}

See also