tailieunhanh - Thủ thuật lập trình cho iPhone part 3
Cuối cùng, chúng tôi nhận được để viết một số mã thực sự! Trong hướng dẫn này, tôi sẽ chỉ cho bạn cách để tạo ra một giao diện sử dụng giao diện Builder và kết nối nó với code của bạn. Chúng tôi sẽ tạo ra một UITextField, UILabel, và một Button. | Bai 4 Connecting Code to An Interface Builder View Finally we get to write some real code In this tutorial I will show you how to create an interface using Interface Builder and connect it to your code. We will be creating a UITextField UILabel and a Button. Now don t be intimidated that this tutorial is so long. I have really went into detail explaining everything as I go. You could easily scan over it and get the gist of it. Here s how the application will work 1. The user will tap inside a text box which brings up the iPhone s keyboard 2. The user will type their name using the keyboard 3. The user will press a button 4. The label will update with a greeting containing that user s name ex. Hello Brandon 5. If the user fails to enter in text the label will say something like Please Enter Your Name Prerequisites This tutorial assumes that you have completed the following tutorials Hello World Tutorial Using UITableView Beginner Interface Builder In this tutorial you will learn Create a new View-Based application Create a simple user interface Write code to connect to an interface Connect the interface to the code Update the interface based on user interaction Like the last tutorial I wrote we are going to need only one view. So we will just use Apple s View-Based Application template. So click File - New Project. Select View-Based Application and name it ViewBased You can name it whatever you want . Collection By traibingo So like last time Apple has provided us with most of the code needed to get this app up and running. You can click Build and Go to launch the simulator but all you will see is blankness. Let s get started by double clicking on . This is a nib file that opens with Interface Builder. It contains information regarding the layout and controls of our view. Once you do this Interface Builder should open up. It will look something like the screenshot below. A few notes about interface builder. Library - The right-most window
đang nạp các trang xem trước