Article Two: _uicascadingtextstorage Attributesatindex:effectiverange:]: Range or index out of bounds

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.