datePickerViewController.h
#import <UIKit/UIKit.h> @interface datePickerViewController : UIViewController { UIDatePicker *selectTime; IBOutlet UILabel *label; IBOutlet UITextField *textField; } @property(nonatomic, retain)IBOutlet UIDatePicker *selectTime; -(IBAction)buttonPressed; @end
datePickerViewController.m
#import "datePickerViewController.h" @implementation datePickerViewController @synthesize selectTime; -(IBAction)buttonPressed{ NSDate *choice = [selectTime date]; NSString *message = [[NSString alloc] initWithFormat:@"The date is %@", choice]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"The title" message:message delegate:nil cancelButtonTitle:@"close" otherButtonTitles:nil, nil]; [alert show]; [alert release]; [message release]; label.text = message; textField.text = message; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; self.selectTime = nil; [super viewDidUnload]; } - (void)dealloc { [selectTime release]; [super dealloc]; } @end
参考
YouTube - XCode 4 Tutorial Date Picker - Geeky Lemon Developmenthttp://www.youtube.com/watch?v=qW9nJgk9XwI&hd=1
詳解 Objective-C 2.0 改訂版: 荻原 剛志 | iPhoneプログラミングUIKit詳解リファレンス: 所 友太, 京セラコミュニケーションシステム株式会社 | iPhone SDK アプリケーション開発ガイド: Jonathan Zdziarski, 近藤 誠 (監訳), 武舎 広幸, 武舎 るみ |
0 コメント:
コメントを投稿