Quick Start Ios
Quick Start Ios
iOS QuickStart
From Xojo Documentation
Welcome to Xojo the best cross-platform you've never heard of. With Xojo you can make apps
for Windows, macOS, Linux, Raspberry Pi, iOS and the web. Xojo is made up of a rich set of
graphical user interface objects, a modern object-oriented language, an integrated debugger,
and a multi-platform compiler. Together they make up the Xojo Integrated Development
Environment or IDE.
With the IDE, you can build your app’s interface simply by dragging and dropping interface
objects into the app’s layout views. In this QuickStart, you will see how easy it is. Xojo provides
you with all the tools you need to build virtually any app you can imagine.
This QuickStart is for people who are new to programming and new to Xojo. It will give you a
gentle introduction to the Xojo development environment and lead you through the development
of a working iOS app (a simple web browser). It should take you about 15 minutes to complete
this QuickStart. If you are short on time, you can also watch the 5-minute video or download the
finished project:
3.1 Overview
3.2 Building the User Interface
3.3 Setting the Properties
4 What's Next
Getting Started
If you haven’t done so already, now is the time to start Xojo.
1. Double-click the Xojo app icon to start Xojo. After it finishes loading, the Project Chooser
window appears.
2. Xojo lets you build several different types of apps (Desktop, Web, Console and iOS). For this
QuickStart, you are building an iOS app, so click on iOS.
3. You should now see three fields that need values: Application Name, Company Name and
Application Identifier.
1. Application Name is the name of your app. This will be the filename of the actual app file
that gets created.
2. Company Name is the name of your company. You may choose to leave this blank.
3. Application Identifier is a unique identifier for this app. It will automatically populate using
what you enter for the Application and Company Names, but you can also change it to
whatever you want.
4. Enter "SimpleBrowser" as the Application Name. You can leave Company Name as it is or
change it.
5. Click OK to open the main Xojo window (called the Workspace), where you will begin
designing your app.
Workspace
Xojo opens the Workspace with the default view for your app automatically selected in
the Navigator and displayed in the Layout Editor.
Navigator: The area on the top left shows you all the items in your project. By default you can
see View1 (which is selected), the App object and the iPhone and iPad screen items. You use
the Navigator to navigate to the various items within your project.
Layout Editor: The center area is the Layout Editor. You use the Layout Editor to design the user
interface for the views in your app. It shows the view and previews how it looks when the app
runs. In this illustration, the view is blank because you haven't yet added any user interface
controls from the Library.
Library: The area on the right is the Library and shows the controls and interface elements that
you can add to a view or to the project. You design the view by dragging controls from the
Library to the view. You can also add a control to the view by double-clicking it. You can change
how the controls display in the Library by clicking the small gear iconand choosing a different
setting.
Note: If the Library is not visible, click the Library button on the toolbar to show it.
Inspector: Not shown in the above illustration is the Inspector, which allows you to see and
change the properties for the selected control. This area of the Workspace window is shared
with the Library. You can show the Inspector by clicking the Inspector button on the toolbar. The
Inspector shows information about the selected item in the Navigator or Editor. The contents of
the Inspector changes as you click on different items. You change an Inspector value by entering
a new value in the field to the right of the field label.
A Xojo app consists of a collection of objects, called classes. Nearly everything in Xojo is a
class, including your views and its controls. In the SimpleBrowser project, you use the default
View class to create your view and you add controls (user interface classes) to the view to create
the design.
The app uses three controls:
Text Field: A Text Field control is used to enter text. In this project, the URL to display is
typed into a Text Field at the top of the view.
Button: A Button is used to trigger an action. The user clicks the button to load the web
page at the URL into the HTML Viewer.
HTML Viewer: An HTML Viewer is used to display HTML (a web page). In this project, it is
what displays the web site at the URL.
The next sections walk you through creating the user interface and adding the necessary code
to make the app work.
1. Starting with Text Field: In the Library, click on the Text Field icon and drag it to the top-left
corner of the view in the Layout Editor. As you get close to the edges of the view, you will
see alignment indicators that help you position the control.
2. Next, add the Button: In the Library, click on the Button icon and drag it to the top-right
corner of the view.
3. The final control is the HTML Viewer: Drag the HTML Viewer icon to the remaining empty
area on the view. Resize this control (using the selection handles so that it fills most of the
view below the Text Field and Button) and use the locking guides that appear to help align it
to the edges.
4. The final step is to resize the Text Field so that it is larger. Click on it to show the selection
handles. Click the center-right handle and drag it to the right until the alignment guides tell
you it is close enough to the Button.
Rename all controls (and the view) so that they describe their behavior and are easy to refer
to in code.
Add a Caption to the Button.
Set Auto-Layout properties so that the controls resize properly for different sized iOS
devices.
Inspector
The Inspector is used to change view and control properties. It shares the same area on the right
of the Workspace as the Library. In order to show the Inspector, click the Inspector button on the
toolbar or press ⌘-I (Ctrl+I on Windows and Linux).
First, in the Layout Editor, click on the iPhone border of the view to select it. The Inspector
now shows the properties for the view.
In the Name field (located in the ID group), change the name from "View1" to
"BrowserView". Press Return to see the name change in the Navigator.
In the NavigationBarVisible field, set the switch to ON. This displays the Navigation Bar for
the view. When you do this, the Text Field and Button may disappear as they are covered by
the Navigation Bar. You can fix this in the next sections.
In the Title field, change the name to “SimpleBrowser”. Press Return and you will see the
name change in the Navigation Bar.
If you did not align the Text Field using the layout guides, you may need to make changes to
Auto-Layout so that the Text Field gets larger or smaller as the size of the view changes when
different devices are used.
1. In the Auto-Layout section you will see a list of rules that control how the Text Field appears
on the view. In particular, you want to change the Top rule so that it indicates to put the Text
Field at a standard gap below the TopLayoutGuide. To do this, click on the "Top" rule and
then click the Edit button.
2. Set the values for the Auto-Layout rule as below and click Done:
1. On BrowserView, select the Button1 control. The Inspector changes to show the Button
properties.
2. In the Name field, change the name from "Button1" to "ShowButton". Press Return to see
the name change in the Navigator.
3. Give your button a caption by changing the Caption field from "Untitled" to "Show".
If you did not align the Button using the layout guides, you may need to make changes to Auto-
Layout so that the Button stays below the navigation bar and stays attached to the right side of
the view when the device size changes.
1. In the Auto-Layout section you will see a list of rules that control how the Button appears on
the view. In particular, you want to change the Top rule so that it aligns the button with the
top of the Text Field and the Right rule to ensure the Button stays on the right side of the
view.
2. First click on the "Top" rule and then click the Edit button. If the Top rule is not displayed,
you can add it using the "+" button at the bottom of the Auto-Layout area. Set the values for
the Auto-Layout rule as below and click Done:
3. Lastly, click on the Right rule, click Edit, set its values as below and click Done:
Finally, you may need to change Auto-Layout so that the HTML Viewer displays using the rest of
the area in the View. Specifically you will change these Auto-Layout rules: Top, Left and Right
(You may not have to change all rules if you used the layout guides to position the HTML
Viewer).
1. Select the Top rule, click Edit and set is values as below:
2. Select the Left rule, click Edit and set its values as below:
3. Select the Right rule, click Edit and set its values as below:
Remember, if any rule you want to edit is not in the list of rules, you can add it by using the "+"
button at the bottom of the Auto-Layout section of the Inspector.
Adding Code
Your app is almost complete. Now it is time to add the code that will tell the HTML Viewer
(called WebViewer) the web page to display. Xojo uses an object-oriented programming
language which is quite easy to learn. You need only one line of code to finish your project!
1. Figure out when your user clicks the ShowButton, called "Show" on the view.
2. Get the URL that your user entered in URLField.
3. Have WebViewer display the URL.
Follow these steps to add the code:
1. In order to run an iOS project, you first need to download and install Xcode in order to get
the iOS Simulator app that is used to run iOS apps on a Mac. You can download Xcode for
free from the Mac App Store. After you have downloaded and installed Xcode, you need to
run it one time to accept its License Agreement. After doing this, you can quit Xcode as
you will not need it.
2. Click the Run button in Xojo to run the app in the iOS Simulator.
3. Type a (secure, https) URL of your choice (or use the default) and click the "Show" button.
4. You will see the web page.
5. When you are finished experimenting with the Simple Browser app, you can quit the iOS
Simulator to return to Xojo.
If you want to use non-secure (standard http URLs) with iOS 9 or later, you will need to
configure iOS App Transport Security as described in this blog post. Or refer to
the iOSHTMLViewer page for additional information.
What's Next
This QuickStart has introduced you to Xojo and showed you how to make a simple app.
Next, you should view the the User Guide and iOS Language Reference.