I can't get my head round - (void)playInputClick;
cocoa-touch, ios, iphone, objective-c, uikit
Solution
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
}
Problem
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. Does anyone know how to make this work? There seems to be no example code of this method being used anywhere on the internet.