#import "DatePickerViewController.h"
#import <Parse/Parse.h>
@interface DatePickerViewController ()
@end
@implementation DatePickerViewController
@synthesize dateLabel;
@synthesize pick;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UIBarButtonItem *saveDate = [[UIBarButtonItem alloc]
initWithTitle:@"Save Date"
style:UIBarButtonItemStyleDone
target:self
action:@selector(saveList:)];
self.navigationItem.rightBarButtonItem = saveDate;
pick = [[UIDatePicker alloc] init];
[pick setFrame:CGRectMake(0,200,320,120)];
[pick addTarget:self action:@selector(updateDateLabel:) forControlEvents:UIControlEventValueChanged];
}
-(void)saveList:(id)sender {
// need to finish
}
-(IBAction)updateDateLabel {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterLongStyle];
[formatter setTimeStyle:NSDateFormatterMediumStyle];
dateLabel.text = [NSString stringWithFormat:@"%@", [formatter stringFromDate:pick.date]];
}
问问题
383 次
2 回答
1
您对来自选择器的事件的注册正在使用一个需要一个参数的选择器(@selector(updateDateLabel:)
需要一个表单的方法-updateDateLabel:(id)arg
),而您实现的内容不带任何参数(-updateDateLabel
)
当然,考虑到您已经从故事板中取消归档的选择器中重新分配了选择器,所有这些都没有实际意义。删除初始化代码并将 IBAction 连接到情节提要中的选择器。
于 2013-03-16T21:03:14.403 回答
0
更改-(IBAction)updateDateLabel {
为-(IBAction)updateDateLabel:(id)sender {
于 2013-03-16T21:06:52.430 回答