我正在尝试实现基本的QuickDialog视图,并且元素的放置工作正常。 但是当我选择一个元素时,视图不会将其滚动到视图中。我以为图书馆会自己做这个或者我错过了什么?
这是我的代码:
- (id)initWithCoder:(NSCoder *)aDecoder {
if ((self = [super initWithCoder:aDecoder])) {
QRootElement *root = [[QRootElement alloc] init];
root.title = @"";
root.grouped = YES;
self.root = root;
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
QSection *driverSection = [[QSection alloc] initWithTitle:@"xxx"];
QEntryElement *lblDriverSsn = [[QEntryElement alloc] initWithTitle:@"xxx" Value:@""];
lblDriverSsn.key = @"driverSsn";
QSection *vehicleSection = [[QSection alloc] initWithTitle:@"xxx"];
NSArray *component1 = @[@"xxx", @"xxx"];
QPickerElement *EventDescriptionPicker = [[QPickerElement alloc] initWithTitle:@"xxx" items:@[component1] value:@""];
EventDescriptionPicker.key = @"eventDescription";
NSMutableArray *speedValues = [[NSMutableArray alloc]init];
for (int i = 0; i <= 201; i+=5)
{
[speedValues addObject:[NSString stringWithFormat:@"%d%@", i,@" km/h"]];
}
QPickerElement *vehicleSpeed = [[QPickerElement alloc] initWithTitle:@"xxx" items:@[speedValues] value:@""];
self.damageReported = [[QBooleanElement alloc] initWithTitle:@"xxx" BoolValue:NO];
self.damageReported.onImage = [UIImage imageNamed:@"imgOn"];
self.damageReported.offImage = [UIImage imageNamed:@"imgOff"];
self.damageReported.controllerAction = @"showReportNumber:";
QEntryElement *lblReportNumber = [[QEntryElement alloc] initWithTitle:@"xxx" Value:@""];
lblDriverSsn.key = @"reportNumber";
//Sections
[driverSection addElement:lblDriverSsn];
[self.root addSection:driverSection];
[vehicleSection addElement:EventDescriptionPicker];
[vehicleSection addElement:vehicleSpeed];
[vehicleSection addElement:self.damageReported];
[vehicleSection addElement:lblReportNumber];
[self.root addSection:vehicleSection];
}
我在这里遗漏了什么吗? 提前致谢
答案 0 :(得分:1)
在你的initWithCoder:上,设置以下内容:
self.resizeWhenKeyboardPresented =YES;
这会导致视图控制器侦听键盘通知,并相应地调整插入。