0
我創建動態畫面和動態創建的文本字段 當我觸摸文本字段,並開始寫,然後我的鍵盤響應速度慢和花費近3-4秒時,在屏幕上顯示一個字符。 我該如何解決這個問題?提前致謝。鍵盤響應緩慢的ios
- (BOOL) textFieldShouldBeginEditing:(UITextField *)textField
{
NSInteger componentType;
BOOL isEditable = YES;
for (int i = 0; i < self.screenComponentData.count; i++)
{
if ([self.keyboardType[i] intValue] == NUMERIC)
{
[textField setKeyboardType:UIKeyboardTypeNumberPad];
}
else if([self.keyboardType[i] intValue] == ALPHA)
{
[textField setKeyboardType:UIKeyboardTypeAlphabet];
}
else if([self.keyboardType[i] intValue] == ALPHANUMERIC)
{
[textField setKeyboardType:UIKeyboardTypeDefault];
}
NSString *str = [self.entityMap objectAtIndex:i];
// str = [str substringFromIndex:2];
if (textField.tag == [str intValue])
{
componentType = [self.screenComponentData[i][3] intValue];
if ([self.screenComponentData[i][7] characterAtIndex:27] == NON_EDITABLE)
{
isEditable = NO;
}
break;
}
}
if (componentType == DATE_PICKER || componentType == TIME_PICKER || componentType == VALUE_PICKER)
{
[self textFieldTouched:textField];
return NO;
}
else if(isEditable == NO)
{
//Dont show picker & dont allow user to edit too.SHOW DEFAULT TEXT
return NO;
}
else
{
return YES;
}
}
- (void) textFieldTouched:(UITextField *)textField
{
NSArray *test1;
NSArray *compoType;
NSArray *tag_Table_Name; //<--table to where to get data
for (int index = 0; index < self.componentType.count ; index++) {
// pooja's code'
if (textField.tag ==60 ||textField.tag ==865 ||textField.tag ==1202 || textField.tag==48)
{
tag_Table_Name=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL13 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
compoType=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL3 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
test1=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL1 FROM TB%@",tag_Table_Name[0][0]]];
if (self.textField.tag== 61) {
[email protected]"";
}
}else if (textField.tag==61){
tag_Table_Name=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL13 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
compoType=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL3 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
test1=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL1 FROM TB%@ WHERE COL2='%@'",tag_Table_Name[0][0],self.codeString]];
}else if (textField.tag==1159){
tag_Table_Name=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL13 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
compoType=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL3 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
test1=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL1 FROM TB%@",tag_Table_Name[0][0]]];
}else if (textField.tag ==1760){
tag_Table_Name=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL13 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
compoType=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL3 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
test1=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL1 FROM TB%@",tag_Table_Name[0][0]]];
}else if (textField.tag==55){
tag_Table_Name=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL13 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
compoType=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL3 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
test1=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL1 FROM TB%@ WHERE COL2='%@'",tag_Table_Name[0][0],self.codeString]];
}else if (textField.tag==861){
tag_Table_Name=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL13 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
compoType=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL3 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
test1=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL1 FROM TB%@ WHERE COL2='%@'",tag_Table_Name[0][0],self.codeString]];
}else if (textField.tag==108 ||textField.tag == 1154 ||self.textField.tag==66){
tag_Table_Name=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL13 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
compoType=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL3 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
test1=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL1 FROM TB%@",tag_Table_Name[0][0]]];
}else if (textField.tag==1153){
tag_Table_Name=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL13 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
compoType=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL3 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
test1=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL1 FROM TB%@",tag_Table_Name[0][0]]];
}
else{
tag_Table_Name=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL13 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
compoType=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL3 FROM %@ WHERE COL0='%@' and COL2='%ld'",TBSYS0001,self.screenId,(long)textField.tag]];
test1=[DBOperator getDataForQuery:[NSString stringWithFormat:@"SELECT COL1 FROM TB%@",tag_Table_Name[0][0]]];
}
if (textField.tag == 64){
self.tagForFollowUpDate = 64;
self.configure.getFollowConfigDate = self.tagForFollowUpDate;
}
if (textField.tag == 45){
self.tagForDOB = 45;
self.configure.getDOB = self.tagForDOB;
}
}
self.textfieldTAG = textField.tag;
NSInteger compo=[compoType[0][0]intValue];
// NSLog(@"COMPO->%d",compo);
switch (compo) {
case DATE_PICKER:
[self displayDatePicker:textField];
break;
case TIME_PICKER:
[self displayTimePicker:textField];
break;
case VALUE_PICKER:
{
if (self.popOver != nil && [self.popOver isPopoverVisible])
{
[self.popOver dismissPopoverAnimated:YES];
}
RMPickerViewController *pickerVC = [RMPickerViewController pickerController];
pickerVC.delegate = self;
pickerVC.backgroundColor = [UIColor whiteColor];
// pickerVC.tintColor = [UIColor yellowColor];
// pickerVC.selectedBackgroundColor = [UIColor yellowColor];
if (self.commanArray != nil && self.commanArray.count > 0)
{
[self.commanArray removeAllObjects];
}
[self.commanArray addObjectsFromArray:[self getdropListDataWithValue:test1]]; //<--- Value Picker
[pickerVC showFromRect:textField.frame inView:self.scrollView];
break;
}
default:
{
//To get the values for making the syncData string
for (int i = 0; i < self.screenComponentData.count; i++)
{
NSString *str=[self.entityMap objectAtIndex:i];
// str = [str substringFromIndex:2];
if (textField.tag == [str intValue])
{
[self.valueArray replaceObjectAtIndex:i withObject:textField.text];
[self.savingArray replaceObjectAtIndex:i withObject:textField.text];
break;
}
}
[textField setKeyboardType:UIKeyboardTypeDefault];
break;
}
}//end of switch case;
;
}// end of textFieldTouched
您是使用真實設備還是模擬器?你可以在你創建並填寫文本字段的地方發佈一些代碼嗎? – 2014-12-03 06:58:15
另外,如果您實施任何,請發佈文本字段委託方法的代碼。 – 2014-12-03 07:00:07
請發佈shouldChangeCharactersInRange委託方法的代碼。您在此委託方法中做了很長時間的處理,因此發生這種情況是其中一個原因。 – 2014-12-03 07:02:17