我不能让我的头圆 - (void)playInputClick; [英] I can't get my head round - (void)playInputClick;

查看:447
本文介绍了我不能让我的头圆 - (void)playInputClick;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于UITextField设置的inputAccessoryView,它在需要时从XIB加载(与Apple的KeyboardAccessory示例完全相同)。

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).

m尝试获取其上的按钮点击时使用playInputClick函数,但我无法解决如何。 苹果文档说,我需要添加一个委托方法到视图,但该视图是纯粹在界面构建器中创建的,所以我不知道我该怎么做。

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.

推荐答案

假设你试图这样做a inputAccessoryView:

Assuming you are trying to do this in an inputAccessoryView:

.h 文件中,指示您实现 UIInputViewAudioFeedback

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

@interface YourAcessoryView : UIView <UIInputViewAudioFeedback>

.m 方法来满足协议

- (BOOL)enableInputClicksWhenVisible {
    return YES;
}

按下按钮时,执行以下操作:

When a button is pressed, do something like:

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

这篇关于我不能让我的头圆 - (void)playInputClick;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆