我有一个定义如下的注册表单,我喜欢在滚动视图中使用这个表单,这样如果用户选择底部的文本字段,它就会滚动。
问题是,注册表单没有覆盖整个屏幕,在后台我仍然有主视图,我希望文本字段在表单内滚动,而不改变表单窗口的位置(我不想要表单视图出现并覆盖背景)。
- (UIView *)Form
{
if (!_Form) {
CGRect frame = CGRectMake(0.0, Height, Width, 310.0);
UIView *container = [[UIView alloc] initWithFrame:frame];
CGFloat y = 15.0;
frame = CGRectMake(15.0, y, width, height);
UITextField *field = [[UITextField alloc] initWithFrame:frame];
[
field.placeholder = @"text1*";
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*";
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*";
y = frame.origin.y + kDefaultTextFieldHeight + 16.0;
CGFloat w = (kDeviceWidth - 2 * 15.0) / 2;
frame = CGRectMake(15.0, y, w - 2.0, height);
field = [[UITextField alloc] initWithFrame:frame];
field.placeholder = @"First Name*";
frame = CGRectMake(15.0 + w + 2.0, y, w - 2.0, height);
field = [[UITextField alloc] initWithFrame:frame];
field.placeholder = @"Last Name*";
[container addSubview:field];
y = frame.origin.y + kDefaultTextFieldHeight + spacing;
frame = CGRectMake(15.0, y, w, kDefaultTextFieldHeight);
field = [[UITextField alloc] initWithFrame:frame];
field.placeholder = @"Birthday";
y = frame.origin.y + kDefaultTextFieldHeight + 20.0;
frame = CGRectMake((container.frame.size.width - 192.0) / 2, y, 192.0, 34.0);
y = frame.origin.y + kDefaultTextFieldHeight + 8.0;
frame = CGRectMake((container.frame.size.width - 192.0) / 2, y, 192.0, 34.0);
_Form = container;
}
return _Form;
}
谢谢!