實現點擊一個按鈕,在對應的文本框內顯示當前日期時間(Xcode6.1版本)
// // ViewController.h // 1129_HelloWolrd // // Created by God Lin on 14/11/29. // Copyright (c) 2014年 arbboter. All rights reserved. // #import@interface ViewController : UIViewController { UITextField* textTime; } @property (nonatomic, retain) IBOutlet UITextField* textTime; -(IBAction)onClickTimeBtn:(id)sender; @end
//
// 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 that can be recreated.
}
@end