zoukankan      html  css  js  c++  java
  • Objetive C view

    Creating the View

    One label and two buttons

    One butoon will generate the seed, another button will generate the random number, and the label shows the random number generated by the app.
    Drag a Label from the library Pane Controls section to the View Window.

    Drag two rounded rect buttons

    Click the top button and label the button Seed Random Number Generator

    quickly and easy connect our Outlests and Actions to our code.

    Click the Assistant Editor icon  at the top right of the screen.This will display the .h file for the XIB file we are working on ,

    Using Outlets

    Insert curly brackets for your instance variables.

    .h file

    A popup window will appear .This enables us to name and specify the type of Outlet.

    @interface ViewController : UIViewController

    {

      IBOutlet UILabel *randomNumber;

    }

    @end

    As a reminder,outlets(pointers) are declared in our object's interface file and connected to specific instance variables.

    simply as an outlet.

    Outlets signal your controller that this instance variable is a pointer to another object that is set up in Intrface Builder, we can connect these instance variables to the appropriate object.

    Connecting Actions and Objects

    connect the object actions to the buttons

    Control-Drag from the Seed Random Number Generator button to below the last curly bracket and drop.

    connection is an Action

    Repeat Step 8 for the Generate Random Number button.

    #import <UIKit/UIKit.h>

    @interface ViewController : UIViewController

    {

      IBOutlet UILabel *randomNumber;

    }

    _ (IBAction)seed:(id)sender;

    _(IBAction)generate:(id)sender;

    @end

    Implementation File

    ViewController.m file and complete the seed: and generate: method

    _ (IBAction)seed:(id)sender{

      srandom(time(NULL));

      [randomNumber setText: @"Generator seeded"];

    }

    _ (IBAction)generate:(id)sender {

      int generated;

      generated = (random() % 101);

      [randomNumber setText:[NSString stringWithFormat:@"%i",generated]];

          set the UILabel value in your view.

        

    }

    sets the UILabel value in your view.

    XIB files

    Model-View-Controller

    Architectural pattern

    Human interface guidelines(HIGS)

    Outlets

    Actions

  • 相关阅读:
    《命运赋》
    CSS3中的 transform (变形)+Transition(转换) = animation(动画)
    c#进阶之泛型
    正则表达式运用
    查询某时间段的统计数据
    很好用的request转换为实体方法还有判断实体所有参数不能为空的方法
    http 协议集合,超级简单
    今天无意发现jquery的一个以前的误导
    IFRAM随内部长宽高变化
    就最近学习MVC4.0的页面用法学到的东西
  • 原文地址:https://www.cnblogs.com/yushunwu/p/2626051.html
Copyright © 2011-2022 走看看