I can't get my head round – (void)playInputClick;

I have an inputAccessoryView for a UITextField set up, which is loaded from a XIB when needed (in the exact same way as Apple’s KeyboardAccessory example).

I’m trying to get the buttons on it to click when pressed using the playInputClick function but I can’t work out how. The Apple documentation says that I need to add add a delegate method to the view, but the view was created purely in interface builder so I don’t see how I can do this.

  • Crash when open containing app from today extension
  • Circular button becomes rounded rectangle after size increase
  • Offscreen UITableViewCells (for size calculations) not respecting size class?
  • How do I inspect the view hierarchy in iOS?
  • Passing arguments to selector in Swift3
  • Bad Access on
  • Does anyone know how to make this work? There seems to be no example code of this method being used anywhere on the internet.

    3 Solutions Collect From Internet About “I can't get my head round – (void)playInputClick;”

    I’ve been having the same problem and finally figured it out.

    If you implement the protocol in a UIViewController it does not work. It needs to be implemented in a UIView subclass.

    So to get it working, I created a view in interface builder with a view controller. Then I added another class which is a subclass of UIView. This class implements the UIInputViewAudioFeedback protocol. Then in interface builder I went to the Identity inspector of my view and changed the class to my UIView subclass which implements the UIInputViewAudioFeedback protocol. And the keyboard click sound is now working.

    My view controller is still calling the [[UIDevice currentDevice] playInputClick], all I did was move the code for the UIInputViewAudioFeedback protocol into a UIView Subclass and set my views class to my UIView sublass.

    Assuming you are trying to do this in an inputAccessoryView:

    In the .h file, indicate that you implement the UIInputViewAudioFeedback

    @interface YourAcessoryView : UIView <UIInputViewAudioFeedback>

    In the .m file, add this method to satisfy the protocol

    - (BOOL)enableInputClicksWhenVisible {
        return YES;

    When a button is pressed, do something like:

    - (void)buttonPressed:(UIButton*)sender
        [[UIDevice currentDevice] playInputClick];
        // do more stuff

    You need to implement a view controller class, and in the interface builder assign the files’owner as this class. Connect the view controller’s view to your view.

    Once you have done that you can implement the delegate in the view controller.
    Its pretty simple and straight forward. Basically your view will be a member of a view controller class.