My First RubyMotion App: Very Simple Web Browser


Japanese Version

I try to development my fisrt RubyMotion App.
It’s a very simple web browser.

The following is snapshot of finished product.

Let’s start.

Creating Project

Create and Run “Browser” project.
Still blank, black background app.

No problem.

White Background ViewController

Next, add white background ViewController.
Wrap by NavigationController for easy using NavigationBar.

Here is AppDelegate.

Here is BrowserViewController.
Now, only setting backgroundColor.

Showing Toolbar and NavigationBar

NavigationBar is displayed by default.
So, I just set Toolbar’s hidden to false in BrowserViewController#viewDidLoad.

Loading Google by WebView

Adding UIWebView.
And defining “loadRequest” method for loading webpage.

delegate is set to self.


Adding LocationBar

Creating TextField for inputting URL.
Adding to NavigationBar and call “loadRequest” in textFieldShouldReturn.
(delegate is self)

Ref: NavigationBarにテキスト欄を表示させる | nk-z.memo

Forward, Back, Refresh, Stop

Adding buttons to toolbar, and set action for calling webView’s methods.

Ref: ツールバーのボタン (UIBarButtonItem) の隠し API – 24/7 twenty-four seven

Adjustment for Usability

Showing indicator when loading, and switch Enable/Disable buttons in Delegate methods of webView.

Ref: UIWebView下で、UIButtonの活性/不活性にする: iPhoneアプリ開発備忘録


That’s all. Did you have fun?

Full source code is available on GitHub.
I’ll add other samples soon.
RubyMotionApps/Browser at master · tnantoka/RubyMotionApps · GitHub

Enjoy iOS Development by Ruby :-)

Sorry for my English.

One Response to My First RubyMotion App: Very Simple Web Browser


Your email address will not be published. Please enter your name, email and a comment.