Search code examples
iosobjective-cuitoolbarundoredo

How do I add an clear/redo button in a UIToolBar?


I have a "Clear" button. It clears 2 text fields back to being empty.

When the user clicks the "Clear" button once, I want it to change or become another button that adds back what it cleared. Like a "Redo" button.

How can I go about doing this? So far this is what my "Clear" button does:

- (IBAction)clearButton:(UIBarButtonItem *)sender {
    _inputTextField.text = @"";
    _outputTextField.text = @"";
    _characterCount.text = @"0";
    _characterCount.textColor = [UIColor blackColor];
}

I used to be able to use shake-to-undo, but after updating to iOS8 and xCode, no matter if I shake it, the redo menu does not pop up. It used to back in iOs7, but all it did was crash the application. Is there a way to fix this? I have it enabled but it just doesn't show up anymore.

Please don't berate my question. I tried searching but couldn't find it for a toolbar for iOS.


Solution

  • Hi I have create a new project on your requirement , have a look and reply :

    https://github.com/ksbani/StapperRepo/archive/master.zip