次のようなサインアップフォームを設計しました。このフォームには、いくつかのテキストフィールドが含まれており、ユーザーがテキストフィールドをクリックするたびに、キーボードが表示されるか、誕生日のdatePickerが表示されます。サインアップフォームはタップを使用して表示されます。
しかし、フォーム自体がジャンプして画面全体を覆い、
viewDidLoadとコードのデザインを1)スクロールビュー形式のサインアップフォームに変更して、フォームが画面にジャンプしないようにするにはどうすればよいですか?
- (UIView *)signUpForm
{
if (!_signUpForm) {
CGRect frame = CGRectMake(0.0, kSignUpViewVisibleHeight, kDeviceWidth, 310.0);
UIView *container = [[UIView alloc] initWithFrame:frame];
CGFloat y = 15.0;
frame = CGRectMake(15.0, y, kDeviceWidth - 2*15.0, kDefaultTextFieldHeight);
UITextField *field = [[UITextField alloc] initWithFrame:frame];
field.placeholder = @"Email*";
field.keyboardType = UIKeyboardTypeEmailAddress;
[container addSubview:field];
self.Email = field;
self. Email.delegate = self;
self.Email.clearButtonMode = UITextFieldViewModeWhileEditing;
CGFloat spacing = 8.0;
y = frame.origin.y + kDefaultTextFieldHeight + spacing;
frame = CGRectMake(15.0, y, kDeviceWidth - 2*15.0, kDefaultTextFieldHeight);
field = [[UITextField alloc] initWithFrame:frame];
field.placeholder = @"Password*";
field.secureTextEntry = YES;
[container addSubview:field];
self.password = field;
self.password.delegate = self;
self. password.autocapitalizationType = UITextAutocapitalizationTypeNone;
self. password.clearButtonMode = UITextFieldViewModeWhileEditing;
frame.size.height = 200.0;
y = frame.origin.y + kDefaultTextFieldHeight + spacing;
frame = CGRectMake(15.0, y, kDeviceWidth - 2*15.0, kDefaultTextFieldHeight);
field = [[UITextField alloc] initWithFrame:frame];
field.placeholder = @"Confirm Password*";
field.secureTextEntry = YES;
[container addSubview:field];
self.ConfirmPassword = field;
self. ConfirmPassword.delegate = self;
self. ConfirmPassword.autocapitalizationType = UITextAutocapitalizationTypeNone;
self.registrationFormConfirmPassword.clearButtonMode = UITextFieldViewModeWhileEditing;
y = frame.origin.y + kDefaultTextFieldHeight + 16.0;
CGFloat w = (kDeviceWidth - 2 * 15.0) / 2;
frame = CGRectMake(15.0, y, w - 2.0, kDefaultTextFieldHeight);
field = [[UITextField alloc] initWithFrame:frame];
field.placeholder = @"First Name*";
[container addSubview:field];
self.firstName = field;
self. firstName.delegate = self;
self. firstName.clearButtonMode = UITextFieldViewModeWhileEditing;
frame = CGRectMake(15.0 + w + 2.0, y, w - 2.0, kDefaultTextFieldHeight);
field = [[UITextField alloc] initWithFrame:frame];
field.placeholder = @"Last Name*";
[container addSubview:field];
self.lastName = field;
self.lastName.delegate = self;
self.lastName.clearButtonMode = UITextFieldViewModeWhileEditing;
y = frame.origin.y + kDefaultTextFieldHeight + spacing;
frame = CGRectMake(15.0, y, w, kDefaultTextFieldHeight);
field = [[UITextField alloc] initWithFrame:frame];
[self.appDel.styleManager decorateTextField:field];
field.placeholder = @"Birthday";
[container addSubview:field];
self.Birthday = field;
self.Birthday.delegate = self;
UIButton *signUpButton = [UIButton buttonWithType:UIButtonTypeCustom];
signUpButton.frame = frame;
[signUpButton setTitle:@"Sign Up" forState:UIControlStateNormal];
[signUpButton addTarget:self action:@selector(signUp:) forControlEvents:UIControlEventTouchUpInside]; [container addSubview:signUpButton];
y = frame.origin.y + kDefaultTextFieldHeight + 8.0;
frame = CGRectMake((container.frame.size.width - 192.0) / 2, y, 192.0, 34.0);
UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
cancelButton.frame = frame;
[cancelButton setTitle:@"Cancel" forState:UIControlStateNormal];
[self.appDel.styleManager decorateButton:cancelButton];
[cancelButton addTarget:self action:@selector(cancelRegistration:) forControlEvents:UIControlEventTouchUpInside];
[container addSubview:cancelButton];
_signUpForm = container;
}
return _ signUpForm;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self.navigationController setNavigationBarHidden:YES];
self.view.backgroundColor = [self.appDel.styleManager appBackgroundGradientWithFrame:self.view.bounds];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(endPageEdit:)];
tap.delegate = self;
[self.view addGestureRecognizer:tap];
[self.appDel.styleManager decorateButton:self.loginWithEmailButton];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardDidShow:)
name:UIKeyboardDidShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardDidHide:)
name:UIKeyboardDidHideNotification
object:nil];