objective c - UITextView space character issue -


i having trouble appending space uitextview.

self.textview.text = [[nsstring alloc] initwithformat:@"%@ ", self.textview.text]; //or nsstring *mystr = @"hello!"; mystr = [[nsstring alloc] initwithformat:@"%@ ", mystr]; self.textview.text = mystr; //result should be: hello! <-with space here after end of it. 

how can go appending space uitextview? neither of these methods work. space seems disappear in textview if being trimmed.

thanks!

resolution of problem described below: issue fixed mavericks/xcode 5.0.1 update. appears sdk bug.

i'm having looks exact same problem in terminal app - when hit space (e.g. read text on remote site displaying more) crash because textfield has no space character , therefore range out of bounds. (see below code happens)

- (bool)textviewshouldendediting:(uitextview *)textview {     return no; } 

this keeps textview focused , handling keys pressed. it's way of grabbing keyboard characters 1 one send on telnet client.

- (bool)textview:(uitextview *)textview shouldchangetextinrange:(nsrange)range replacementtext:(nsstring *)text {    nslog(@"—%@— replacementtext", text);   return yes; } 

i see xterminal[37918:c07] — — replacementtext space tapped. didn't have when discovered problem - added sure space being seen uitextview.

- (void)textviewdidchange:(uitextview *)textview {      // determine whether key backspace     if([textview.text isequaltostring:@""]) {         uint8_t bsvalue = ktelnetcharbs;         [connection senddata:[nsdata datawithbytes:&bsvalue length:1]];     } else {         nslog(@"—%@— in output buffer", textview.text);          // not backspace, send 'x'         nsrange allbutx = nsmakerange(1, 1);         [connection sendstring:[textview.text substringwithrange:allbutx]];     }     textview.text = @"x"; } 

i see xterminal[37918:c07] —x— in output buffer

immediately after, , crash @

[connection sendstring:[textview.text substringwithrange:allbutx]];

the space isn't there or nsrange allbutx = nsmakerange(1, 1); ok other printable characters.

there no other delegate methods of uitextview implemented. created

inputtextview = [[uitextview alloc] initwithframe:cgrectzero]; 

and after

inputtextview.text = @"x"; inputtextview.delegate = self; inputtextview.autocorrectiontype = uitextautocorrectiontypeno; [self.view addsubview:inputtextview]; [inputtextview becomefirstresponder]; 

where's space?

update: still no idea why uitextview behaves does. uitextfield works way want, created same way. replace uitextview delegate method textviewdidchange: i'm using this:

[inputtextfield addtarget:self action:@selector(textfielddidchange:) forcontrolevents:uicontroleventeditingchanged]; 

same code otherwise.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -