에 표시하지, 나는 두 날짜 선택기가 있습니다. 둘 다 레이블을 가지고 있으며, 둘 중 하나가 이동되면 그에 따라 업데이트됩니다.UI 날짜 선택기 라벨
은 시작 날짜는 자동으로 오늘 날짜로 설정됩니다. 핵심 데이터를 저장하는 동안 다른 날짜로 변경하지 않으면 레이블에 표시되지 않습니다.
기본적으로 나는 레이블이 오늘 날짜가 있어야 해당 화면을로드, 내가 날짜 선택에서 변경할 경우 변경하는 경우.
나는 뭔가 단순 내려다의 그림,하지만 난 어떤 도움을 주시면 감사하겠습니다 무엇인지 알아낼 수 없습니다.
- (void)viewDidLoad
{
[super viewDidLoad];
svos = self.scrollView.contentOffset;
[self.startDate addTarget:self action:@selector(datePickerChanged:) forControlEvents:UIControlEventValueChanged];
[self.endDate addTarget:self action:@selector(datePickerChanged1:) forControlEvents:UIControlEventValueChanged];
AppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
if(!appDelegate.dateProductionDroneStartDate)
[self.startDate setDate:[NSDate date]];
else
{
[self.startDate setDate:appDelegate.dateProductionDroneStartDate];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM-dd-yyyy "];
NSString *strDate = [dateFormatter stringFromDate:self.startDate.date];
self.productionDroneStartDate.text = strDate;
}
NSDate *now = [NSDate date];
NSDateComponents *components = [[NSDateComponents alloc] init];
[components setDay:1];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *newDate2 = [gregorian dateByAddingComponents:components toDate:now options:0];
if(!appDelegate.dateProductionDroneEndDate)
[self.endDate setDate:newDate2];
else
{
[self.endDate setDate:appDelegate.dateProductionDroneEndDate];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM-dd-yyyy "];
NSString *strDate = [dateFormatter stringFromDate:self.endDate.date];
self.productionDroneEndDate.text = strDate;
}
self.txtProductionName.text = appDelegate.strProductionName;
self.txtProductionScene.text = appDelegate.strProductionScene;
self.txtProductionReel.text = appDelegate.strProductionReel;
self.txtProductionName.delegate = self;
self.txtProductionReel.delegate = self;
self.txtProductionScene.delegate = self;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(dismissKeyboard)];
[self.view addGestureRecognizer:tap];
}
도움 주셔서 감사합니다. 그래서 줄 self = [super initWithNibName : 0 = nibNameOrNil 번들 : nibBundleOrNil];에 오류가 발생했습니다. 표현식을 할당 할 수 없습니다. 예상되는 표현을 말하는 다른 하나, NSDate * newDate2 = [gregorian dateByAddingComponents : components toDate : now options : 0]; 호환되지 않는 포인터 유형을 말합니다. 이것은 NSDate 포매터가 이제 두 번 선언 되었기 때문입니까? –
@ user3856938 게시글을 수정했습니다 ...! 또한 [super initWith ..]가 호출되는 곳입니다. 이 변경 사항은 그들과 관련이 없습니다! – nikhil84