我是 iOS 新手,并不熟悉它的所有 API。我发现了如何在文本字段中显示选定的日期,但我不知道要写什么来显示与特定日期相关的特定(选定)文本。
这是我用来显示日期的代码。你知道我需要改变什么才能在特定日期写我自己的文本吗?:
#import "ViewController.h"
@implementation ViewController
@synthesize datePicker;
@synthesize dateLabel;
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[self setDateLabel:nil];
[self setDatePicker:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (IBAction)touchButton:(id)sender {
NSDate *dateSelect = [datePicker date];
NSString *dateStamp = [[NSString alloc]initWithFormat:@"The date is %@", dateSelect];
dateLabel.text = dateStamp;
}
@end
(我有一个按钮、日期选择器和一个文本字段)
我真的很感激你的回答。