Start developing IOS Apps Today

Source: Internet
Author: User

View Types-view Common Types

Align: Calibration. Create a calibration limit, such as centering a view in his container or calibrating the left edge of two view

Pin: Creates a spacing limit, such as defining a view's height or assigning him a horizontal distance to another view.

Resolve Auto Layout Issues: solves layout problems by adding or re-setting suggestion limits.

Resizing Behavior: Indicates how resizing is used for throttling.

View Controllers

a view controller isn ' t part of the view hierarchy, and it's not a element in your interface. Instead, it manages the view objects in the hierarchy and provides them with behavior. Each content view hierarchy this you build in your storyboard needs a corresponding view controller, responsible for MANAG ing the interface elements and performing tasks in response to user interaction. This usually means writing a custom uiviewcontroller subclass for each content view Hierar Chy. If the Your app has multiple content views, you use a different custom view controller class for each content view.

View Controller is not part of the view hierarchy and is not an element of your interface. He manages view objects and provides them with behavior in hierarchical relationships. Each content view you create in storyboard requires a corresponding view The controller is responsible for managing interface elements and behavior tasks. This usually means creating a custom Uiviewcontroller subclass for each content view level. If your app has multiple content view, you can create a different custom view controller for each content view.

View controllers play many roles. They coordinate the flow of information between the app ' s data model and the views that's display that data, manage the life Cycle of their content views, and handle orientation changes if the device is rotated. But perhaps their most obvious role was to respond to user input.

The view controller plays many roles. They coordinate the information flow between the app data model and the views of the presentation data. Manages the life cycle of the content view and handles direction changes as the device rotates. But perhaps their primary function is to respond to user input.

You also use view controllers to implement transitions from one type of content to another. Because IOS Apps has a limited amount of space in which to display content, view controllers provide the infrastructure n eeded to remove the views of one view controller and replace them with the views of another.

You also use the view controller to perform the delivery of content from one content to another. Because the iOS app has a space limit for displaying content, view Controller provides work to remove a view from a view controller and replace it with another view.

To define interaction in your apps, you make your view controllers files communicate with the ' views ' in your storyboard. Defining connections between the storyboard and source code files through actions and outlets.

To define the interactions in your app, you can communicate between view controller files and views in another storyboard. You use actions and outlets to define the connection between storyboard and source code files.

Navigation Controllers

If your app has more than one content view hierarchy, you need to be able to transition between them. For this, you'll use a specialized type of view CONTROLLER:A navigation Controller ( UINavigationController ). A navigation controller manages transitions backward and forward through a series of view controllers, such as WH En a user navigates through email accounts, inbox messages, and individual emails in the IOS Mail app.

If you have multiple content view layers, you need to be able to transition between them. To achieve this, you will use a specific type of view controller: a navigation controller (Uinavigationcontroller). A navigation Controller management is passed backwards and forwards between a series of view controllers.

The set of view controllers managed by a particular navigation controller was called its navigation stack. The navigation stack is a last-in, first-out collection of Custom View controller objects. The first item added to the stack becomes the root view controller and is never popped off the stack. Other view controllers can is pushed on or popped off the navigation stack.

A series of view controllers managed by the Naviagation controller is called his navigation stack. The navigation stack. The navigation stack is a last-in, first-out collection of custom View controller objects. The first item added will become the root view controller. And will never popped off the stack. Other view controllers will be pressed into the navigation stack or launched.

Although a navigation controller ' s primary job is to manage the presentation of your content view controllers, it's also R Esponsible for presenting the custom views of its own. Specifically, it presents a navigation bar-the view at the top of the "that" provides context about the user's place In the navigation Hierarchy-which contains a Back button and other buttons you can customize. Every view controller that's added to the navigation stack presents this navigation bar. You is responsible for configuring the navigation bar.

Although the first task of a navigation controller is to manage your content view controllers. He is also responsible for customizing view behavior. In particular, he presents a naviagtion bar-at the top of the screen a view-contains a back button and other buttons that you customize. Each view controller added to the navigation stack displays this navigation bar. You are responsible for configuring navigation bar.

You generally don ' t has to does any work to pop a view controller off of the navigation stack; The Back button is provided by the navigation controller handles. However, you do has to manually push a view controller onto the stack. You can do this using storyboards.

You don't usually need to do anything to pop up a view controller. The return button provided by the navigation controller is responsible for this. But you need to manually push a view controller into the stack, and you can use storyboards to do this.

Working with Foundationvalue Objects

Some examples of Value objects in the Foundation framework is:

    • NSStringandNSMutableString

    • NSDataandNSMutableData

    • NSDate

    • NSNumber

    • NSValue

Collection Objects
    • nsarray and nsmutablearray . An array was an ordered collection of objects. You access a object by specifying it position (that's, its index) in the array. The first element in a array is at index 0 (zero).

    • nsset and nsmutableset . A set stores an unordered collection of objects, with each object occurring only once. You generally access objects in the set by applying tests or filters to objects in the set.

    • nsdictionary and Nsmutabledictionary . A Dictionary stores its entries as key-value pairs; The key is a unique identifier, usually a string, and the value are the object you want to store. You access this object by specifying the key.

Arrayssets

A set ( NSSet ) object is similar to an array, but it maintains an unordered group of distinct objects.

Because sets don ' t maintain order, they offer faster performance than arrays does when it comes-testing for membership.

Because the basic NSSet class is immutable, its contents must being specified at creation, using either an initializer or a C Lass Factory method.

    1. nsset * Simpleset =
    2. [nsset setwithobjects:@ "Hello, world!" @42avalue , anobjectnil];

NSArrayas with, the initWithObjects: and setWithObjects: methods both take a nil -terminated, variable number of arguments. The name of the mutable NSSet subclass is NSMutableSet .

Sets store only one reference to a individual object, even if you try adding a object more than once.

    1. NSNumber *number = @42;
    2. NSSet *numberSet =
    3. [NSSet setWithObjects:number, number, number, number, nil];
    4. // numberSet only contains one object
Dictionariestutorial:add Data

Create a custom class to display the useful data.

This tutorial teaches what to:

    • Work with common Foundation classes co-operation with General Foundation classes

    • Create custom data classes creating a customized data classes

    • Implement a data source and delegate protocol execute a data source and delegate protocol

    • Pass data between view controllers to transfer information between view controllers

Create a Data Class

To create the ToDoItem class

  1. Choose file > New > File (or press command-n).

    A dialog appears that prompts you to choose a template for your new file.

  2. On the left, select Source under IOS.

  3. Select Cocoa Touch Class, and click Next.

  4. In the Class field, type ToDoItem .

  5. Choose NSObject from the "Subclass of" pop-up menu. Inherit from NSObject class

  6. Click Next.

    The save location defaults to your project directory.

    The Group option defaults to your app name, ToDoList.

    In the Targets sections, the Your app is selected and the tests for your app is unselected.

  7. Leave these defaults as they are, and click Create.

To configure the ToDoItem class//Configuration ToDoItem Classes

  1. In the Project Navigator, select ToDoItem.h .

  2. Add the following properties to the interface so, the declaration looks like this:

      1. @interface todoitem: nsobject
      2. @property nsstring *itemname
      3. @property bool completed
      4. @property (readonly ) nsdate *creationdate
      5. @end

    Load the Data //Load Data

    1. In the Project Navigator, select ToDoListTableViewController.m .

      Because the array of items is a implementation detail of your table view controller, you declare it in the .m file ins Tead of the .h file. This makes it private to your custom class.

    2. Add the following property to the interface category Xcode created in your custom table View Controller class. The declaration should look like this:

      1. @interface ToDoListTableViewController ()
      2. @property NSMutableArray *toDoItems;
      3. @end
    3. Find the viewDidLoad method. The template implementation looks like this:

      1. - (void)viewDidLoad {
      2. [super viewDidLoad];
      3. // Uncomment the following line to preserve selection between presentations.
      4. // self.clearsSelectionOnViewWillAppear = NO;
      5. // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
      6. // self.navigationItem.rightBarButtonItem = self.editButtonItem;
      7. }

      The template implementation of this method includes comments, were inserted by Xcode when it created ToDoListTableViewController . Code comments like this provide helpful hints and contextual information in source code files, but you don ' t need them for This tutorial. Feel free to delete the comments.

    4. Update the method implementation to allocate and initialize the toDoItems array in the viewDidLoad method:

        1. - (void)viewDidLoad {
        2. [super viewDidLoad];
        3. self.toDoItems = [[NSMutableArray alloc] init];
        4. }

Start developing IOS Apps Today

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.