Ios-Getting Started example

Source: Internet
Author: User

Program Requirements

Implement click a button to display the current datetime in the corresponding text box (Xcode6.1 version)

Implementing the main steps
    • Modify interface, Open Main.storyboard, use the Interface Editor (IB) to drag and drop a button and text edit box (View)
    • in the interface Editor (IB) face, hold down CTRL , pull a straight line from the button to the top view control, then select the Button event response function in the list to implement the connection between the button press and the response function. (or click the button, from the toolbar on the right, show the touch up inside in the Connections Inspector list and pull a straight line to the view Control on the top of the window. and select the event response function to ) (pull straight from the interface to view Control )
    • Open Interface Editor (IB), from view control pull a straight line to the box, and then select a box variable defined in the list to achieve the link between the Board box and the variable (from the Span style= "font-size:18px" >view control pull Line to interface )
    • Implementing logical Code , including setting variables, writing the response function

Sample code
  • ViewController.h
      viewcontroller.h//  1129_hellowolrd////  Created by God Lin on 14/11/29.//  Copyright (c) 2014 Arbboter. All rights reserved.//#import <UIKit/UIKit.h> @interface viewcontroller:uiviewcontroller{    uitextfield*    Texttime;} @property (nonatomic, retain) iboutlet uitextfield* texttime;-(ibaction) ONCLICKTIMEBTN: (ID) sender; @end

  • Viewcontroller.m
      viewcontroller.m//  1129_hellowolrd////  Created by God Lin on 14/11/29.//  Copyright (c) 2014 Arbboter. All rights reserved.//#import "ViewController.h" @interface Viewcontroller () @end @implementation Viewcontroller@synthesize texttime;-(ibaction) ONCLICKTIMEBTN: (ID) sender{    if (texttime)    {        nsdate* date = [NSDate Date];        Texttime.text = [date description];    }} -(void) viewdidload {    [super viewdidload];    Do any additional setup after loading the view, typically from a nib.} -(void) didreceivememorywarning {    [super didreceivememorywarning];    Dispose of any resources the can be recreated.} @end

Ios-Getting Started example

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.