Note the following red fields:
#pragma mark-input is changed
-(void) textfielddidchanged: (Uitextfield *) textfield{
Once the search keyword changes, the search will be re-searched to prevent data duplication when pulling down
_currentpage = 1;
BOOL ischinese;//Determines whether the current input method is Chinese
if ([[[[Uitextinputmode Currentinputmode] primarylanguage] isequaltostring: @ "en-us"]) {
Ischinese = false;
}
Else
{
Ischinese = true;
}
Remove all spaces in the search
NSString *seachtext = [[_seachtextfield text] stringbyreplacingoccurrencesofstring:@ "" withstring:@ ""];
NSLog (@ "%@", Seachtext);
_seachtextfield.text=seachtext;
if (Ischinese) {//Chinese Input Method
Uitextrange *selectedrange = [TextField markedtextrange];
Get highlighted parts
Uitextposition *position = [TextField positionFromPosition:selectedRange.start offset:0];
There is no highlighted word, the text you have entered is requested
if (!position) {
Dispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (0.2 * nsec_per_sec)), Dispatch_get_main_queue (), ^{
if (_seachtextfield.text.length>50) {
[Applicationdelegate showmsg:@] Enter the search address too long! "InView:ApplicationDelegate.window";
_seachtextfield.text=[_seachtextfield.text Substringwithrange:nsmakerange (0, 49)];
return;
}
DLog (@ "input of English into the state of Chinese characters");
[Self headerrereshing];
});
}else
{
DLog (@ "Copy and paste a lot of text, continue typing will cause crashes : The input of the Lenovo input in the English has not been translated into the state of the Chinese characters will cause a crash");
Judgment on exceeding the limit length and exit directly
Dispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (0.2 * nsec_per_sec)), Dispatch_get_main_queue (), ^{
if (_seachtextfield.text.length>50) {
_seachtextfield.text=[_seachtextfield.text Substringwithrange:nsmakerange (0, 49)];
return;
}
Return
});
}
}else{
Dispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (0.2 * nsec_per_sec)), Dispatch_get_main_queue (), ^{
if (_seachtextfield.text.length>50) {
[Applicationdelegate showmsg:@] Enter the search address too long! "InView:ApplicationDelegate.window";
_seachtextfield.text=[_seachtextfield.text Substringwithrange:nsmakerange (0, 49)];
return;
}
DLog (@ "Enter the state of the English language");
[Self headerrereshing];
});
}
}
Article Two: _uicascadingtextstorage Attributesatindex:effectiverange:]: Range or index out of bounds