views:

44

answers:

1

Hi , every one i create custom keyboard and i have problem iam using my keyboard as textview.inputView = myKeyboardView; my keyboard buttons have this code :

NSMutableString *text = [textPad.text mutableCopy];
    NSRange selectedRange = textPad.selectedRange;

    [text replaceCharactersInRange:selectedRange withString:@"A"];
    textPad.text = text;
    [text release];

so the problem is when i want edit a word from middle of my sentence if i select a word and add some letters to that my button write only ONE Character and if i write some other letters that begin end of sentence ! what can i do to solve this problem ?

//EDIT//: PROBLEM SOLVED

+1  A: 
tc.
thank you but i changed your code works great ! there is no need NSString *replacement = @"A"; and selectedRange.length = replacement.length;
Mc.Lover
You need to update the "selected range" correctly. I made a mistake in my code (oops); it should be fixed now.
tc.