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

  • 相关阅读:
    在java中有关于反射的皮毛----自己的简略认知
    在java中异常中的题目---重要的一点
    在一个陌生的环境里学习新的-----单例
    在java开发环境中,快捷键的使用及用法
    指针(一)
    #ifdef、#ifndef、#else、#endif执行条件编译
    oc中的数组
    控制循环结构
    oc中的枚举
    oc中类的实例化及方法调用
  • 原文地址:https://www.cnblogs.com/yushunwu/p/2626051.html
Copyright © 2011-2022 走看看