I have a view based application which has some textboxes that I'm trying to populate with some pickers. For example, one of them will be for date selection. I'm using the following to add a new view to the bottom of my current view, then scroll the entire view upwards:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
if(textField == [self date]) {
editingDate = YES;
UIDatePicker *pv = [[UIDatePicker alloc] initWithFrame:CGRectMake(0,460,0,0)];
pv.userInteractionEnabled = YES;
[self.view addSubview:pv];
textField.placeholder = @"currently selecting below";
[self scrollTheView:YES];
return NO;
}
return YES;
}
My scrollTheView method executes as follows:
- (void)scrollTheView:(BOOL) moveUp {
int scrollAmount = 212;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
CGRect rect = self.view.frame;
if(moveUp){
rect.origin.y -= scrollAmount;
}
else {
rect.origin.y += scrollAmount;
}
self.view.frame = rect;
[UIView commitAnimations];
}
My problem is that although the display looks perfect, the datepicker control will not accept my input at all. It is simply stuck on the current date. I'm not sure what I'm missing here, probably something simple.