Implement controllers and views

Source: Internet
Author: User

 

? 1.0 Introduction

Ios7 has released many new functions for users and a large number of new APIs for our programmers to use and use. As you may already know, the ios7, which has a large user interface, is now still intact from the first version of IOS, because of this, many apps have changed their encoding assumptions, this user interface will never change. The graphic designer is facing the challenge of creating a user interface and considering the user. The former perience method makes it very suitable for the former and later ios7 user interfaces (UIS ).
In order to write applications as iOS 7, you need to know some basic knowledge about objective-C programming in this book. Objective-C, as its name implies, is an object that can be exploited Based on C and extensions. Objects and classes are the root of Object-Oriented Programming (OOP) languages such as objective-C, Java and C ++, and many others. In objective-C, just like any other object-oriented language (ool), the object you want is not only online, but also primitive. For example, the number-20 (negative 20) can be expressed as a primitive:

NSInteNSInteger myNumber = -20;



The simple line of this Code defines a variable named "mynumber" and "nsinteger", and sets its value to 20. This is how we define the objective-C variable. A variable is the location where a simple name is allocated in the memory. In this case, when we set 20 as the value of the mynumber variable, we tell the machine that will eventually run the code snippet to place the above value in the memory location where the variable is mynumber.
All IOS applications basically use the Model-View-controller (MVC) architecture. Models, views, and controllers are the three main components of IOS applications from the perspective of architecture.

?

 

Model is the application brain. It can compute and create a virtual world in the absence of views and controllers. In other words, the model is considered as a virtual copy of your application and has no appearance!

A view is a window for users to interact with applications. It displays the content of the model most of the time, but in addition, it accepts the operations of the user interface. Any interaction between the user and the application is sent to a view, which can then be captured and transmitted to the model through a View Controller.

In IOS programming, the Controller usually refers to the View Controller I just men-tioned. View controllers can be seen as bridges between models and views. The side explained by this controller is changed and the other side needs to be changed with this information. For example, if the user changes the view field, the controller can ensure that the model changes in response. If the model gets new data, the Controller notifies the view to reflect it.
In this chapter, you will learn how to create the structure of IOS applications and how to create intuitive applications using views and view controllers.
In this chapter, we use a single view application template in xcode for most of the user interfaces (UIS) and components we create. In the example to be reproduced, follow the instructions on page 2nd to "Create and run our first IOS application ". Make sure that your applications are generic, instead of supporting only one of the iPhone or iPad applications. General applications can run on both the iPhone and iPad.

Create and run our first iOS app

After exploring any in-depth objective-C functions, we should briefly introduce how to build a simple IOS application in xcode. Xcode is Apple's ide (integrated development environment). It allows you to create, build, and run apps on iOS simulators and even real iOS devices. We will talk more about xcode and its functions later, but now let's focus on creating and running a simple IOS application. I suppose you have downloaded xcode from the Mac app store computer. Once this step is taken care of, follow these steps to create and run a simple iOS app:
1. Open xcode if it is not already enabled.
2. select new project from the File menu...
3. In the new project window that appears, under the left-hand category of iOS, select the application, and then select single view application on the right. Click [next.
4. Enter a name for all product names on the next screen to make you feel it. For example, you can set your product as the name of my first iOS app. In the organization name section, enter the name of your company, or if you do not have a company, enter anything else that makes sense to you. The organization name is an important part of the information. You can enter it here, but now, you don't have to worry too much. Enter com. mycompany in the company Identifier Field. If you really own your own company or you are creating this application for your work with the company, replace the actual name of the company with mycompany. If you just use it to develop your own experiments, invent the name. Select generic for the device section.
5. Once you have set the above value, you only need to press the next button.
6. You are now asking xcode to save it to a proper place for your project. Select a suitable folder for your project, and then press the create button.
7. As long as your project is created, you can build and run it. However, before you start, make sure that you have removed all IOS devices from your computer. The reason behind this is that, once an iOS device is inserted, xcode will try to build and run your project on the device by default, this has caused some problems with the supply curve (which we have not talked about yet ). So unplug your iOS device and press the big run button in the leftmost corner of xcode. If you cannot find the run button, go to the product menu and select the run menu item.
Look! Your first iOS app is running on the iPhone simulator. Even if the app is not completely impressive, it just shows a white screen in the simulator, which is just the first step towards mastering our bigger goals in the ios sdk, so hurry up, because we are on this journey together.

Next article1.2 define and understand Variables

Implement controllers and views

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.