coder
coder

Reputation: 10520

UITextField - want to show last character entered in full textfield

I am creating an iphone app, and I am using a UITextField. In my textfield, if the user fills the textfield, I would still like the user to see what they are text. I am not using the keyboard to fill the textfield - the values are getting filled in from buttons on a calculator. It there a way to make the textfield show the most recently entered values as it normally would with the keyboard?

Thanks.

Here is the code that populates the textfield:

- (IBAction)number:(id)sender {
NSString *entry = [sender currentTitle];

NSLog(@"%@", entry);

if(justOpenedCalculator){
    total.text = @"";
    total.text = [total.text stringByAppendingString:entry];
    addFirstValueToDiscount = YES;

}else{
    total.text = [total.text stringByAppendingString:entry];
    addFirstValueToDiscount = YES;
}
justOpenedCalculator = NO;
}

Upvotes: 1

Views: 783

Answers (2)

Vincent
Vincent

Reputation: 4409

Make a

@property (nonatomic, retain) IBOutlet UITextField ...

And just assign the value to your textfield.

Upvotes: 0

Legolas
Legolas

Reputation: 12325

I don't see why you could not do it with the textField. Just go over the UITextFieldDelegate methods in the Apple Documentation, and implement it. Here is the LINK !. You need to implement that and instead of doing a justOpenedCalculator you could utilize the textFieldDidBeginEditing method, and other delegate methods for your functions.

Make sure that you do a yourTextField.inputView = yourCustomKeyboard.

Upvotes: 1

Related Questions