[翻译] VENCalculatorInputView

VENCalculatorInputView

https://github.com/venmo/VENCalculatorInputView

 

VENCalculatorInputView is the calculator keyboard that is used in the Venmo iOS app. Available for iOS 5 and beyond. Enjoy.

VENCalculatorInputView是一款计数器样式的键盘,该键盘在 Venmo 中有用到,支持iOS5+,希望你喜欢.

 

 

Installation

The easiest way to get started is to use CocoaPods. Just add the following line to your Podfile:

最简单的安装方式是使用 CocoaPods ,在下面的Podfile中加入以下一行即可.

pod 'VENCalculatorInputView', '~> 1.4'

 

Sample Usage

You can choose to use just VENCalculatorInputView (only the keyboard) and define your own behavior or use VENCalculatorInputTextField (keyboard + text field with money calculation built in).

你可以选择直接使用VENCalculatorInputView(仅仅是键盘)然后定义你自己的行为,或者是直接使用VENCalculatorInputTextField(键盘 + 内置的价格计算样式).

 

Using just the calculator keyboard

1. Set the input view. 设置input view.

Find the UITextField or UITextView that you want to display the keyboard and set its inputView to an instance of VENCalculatorInputView.

找到你想要展示键盘的的UITextField或者是UITextView,然后将VENCalculatorInputView当做实例对象赋值.

myTextField.inputView = [VENCalculatorInputView new];

This will have VENCalculatorInputView display when my TextField becomes firstResponder instead of the system keyboard.

这样子之后,就会让VENCalculatorInputView展示出来,当你的TextField变成第一响应者时(此时并不会展示系统的键盘).

 

2. Implement the <VENCalculatorInputViewDelegate> methods. 实现<VENCalculatorInputViewDelegate>代理方法

First, have a class implement the <VENCalculatorInputViewDelegate> protocol and set myTextField.inputView.delegate to an instance of that class.

首先,先在类中声明<VENCalculatorInputViewDelegate>的协议,然后将myTextField.inputView.delegate设置上.

Next, implement the delegate method that handles keyboard input:

接着,实现代理方法来处理键盘输入事件:

- (void)calculatorInputView:(VENCalculatorInputView *)inputView didTapKey:(NSString *)key {
    NSLog(@"Just tapped key: %@", key);
    // Handle the input. Something like [myTextField insertText:key];
}

Finally, implement the delegate method that handles the backspace key:

最后,实现代理方法来控制键值backspace:

- (void)calculatorInputViewDidTapBackspace:(VENCalculatorInputView *)calculatorInputView {
    NSLog(@"Just tapped backspace.");
    // Handle the backspace. Something like [myTextField deleteBackward];
}

Try it!

You can read more about custom keyboards in Apple's documentation.

如果要了解更多,你可以看一下自定义键盘的文档(Apple's documentation).

 

Using the calculator text field (optimized for money calculation) 使用计算器text field(专门为了计算金钱而优化)

All you need to do is use VENCalculatorInputTextField instead of UITextField and use it like normal text field. It will automagically handle the input and make calculations. Take a look at out ourVENCalculatorInputViewSample project.

所有你需要做的,就是使用VENCalculatorInputTextField来替换UITextField,然后就想使用UITextField那样子来用它.他会自动处理计算结果,你可以在项目demo中查看.

 

Localization

Different regions use different symbols as their decimal separator (e.g. .,). By default,VENCalculatorInputView and VENCalculatorInputTextField use the current locale of the device. You can change it by setting the locale property.

不同的地区会用到不同的符号当做他们常用的符号(例如.,).默认情况下,VENCalculatorInputView与VENCalculatorInputTextField是使用了设备当前区域的符号,你可以通过设置locale属性来修改成你想要的.

 

Testing

We've written some tests. You can run them by opening the project in Xcode and hitting Command-U.

我们已经写了好多测试,你可以在项目中键入 Command - U 来运行测试.

 

Contributing

We'd love to see your ideas for improving this library! The best way to contribute is by submitting a pull request. We'll do our best to respond to your patch as soon as possible. You can also submit a new GitHub issue if you find bugs or have questions. 

Please make sure to follow our general coding style and add test coverage for new features!

我很欢迎看到你提出新点子来改进这个!最后的贡献你力量的方式是拉一个分支.我们将会尽最大努力来添加上你的修改.当然,你也可以提交你遇到的bug到 new GitHub issue 上面帮助我们改进.

请确保遵循我们的代码风格,然后添加一个新特性的测试样例.

 

时间: 2024-09-19 23:57:13

[翻译] VENCalculatorInputView的相关文章

[翻译]JDK 8 兼容性指南

翻译官方文档,删除部分可忽略. 译者:坤谷,井桐,激酶 兼容性是一个复杂的问题. 本文介绍了Java平台潜在的三种不兼容问题: 源码: 源码兼容性问题关注Java源代码转换成class文件是否兼容,包括代码是否仍然可编译. 二进制: 在Java语言规范中,二进制兼容性定义为:"类的改变是二进制兼容的(或者不破坏二进制兼容性),是指如果改变前的类的二进制在链接时没有错误,那么改变后的类在链接时仍然没有错误." 行为 : 行为兼容性包括在运行时执行的代码的语义. 欲了解更多信息,请参阅Op

java.security.Guard翻译

  Overview Package  Class Use Tree Deprecated Index Help JavaTM 2 PlatformStd. Ed. v1.4.2  PREV CLASS   NEXT CLASSFRAMES    NO FRAMES     All Classes SUMMARY: NESTED | FIELD | CONSTR | METHODDETAIL: FIELD | CONSTR | METHOD java.security Interface Gua

翻译CFSSL相关操作文档

我发现国内这个CFSSL资料蛮少的. 但如果深入到K8S认证之后,这块知识又必不可少. (OPENSSL也可实现,但好像不是主流) 于是花了两天快速翻译了一下几个文档. 贡献给有需要的同仁. 如有错误(肯定有!),欢迎提正. 百度网盘共享地址: https://pan.baidu.com/s/1skAQtAH

如何这段C#代码翻译成VB代码?谢谢!

问题描述 如何这段C#代码翻译成VB代码?谢谢! private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { //自动点击弹出确认或弹出提示 IHTMLDocument2 vDocument = (IHTMLDocument2)webBrowser1.Document.DomDocument; vDocument.parentWindow.execScrip

php-java和PHP有纯中文的官方手册吗?还是只有部分的翻译?

问题描述 java和PHP有纯中文的官方手册吗?还是只有部分的翻译? java和PHP有纯中文的官方手册吗?还是只有部分的翻译?我英文不好,能不能学呢? 解决方案 http://cn2.php.net/manual/zh/index.php 解决方案二: java的JDK有中文版的API,PHP网上也有中文手册.现在网络资源这么丰富,只有肯上心,学东西还是很容易的. 选定一个完整的视频教程,跟着练习,上手是很容易的. 我就是2010年暑假跟着传智播客视频教程自学的Java,现在已经很熟练了.祝好

傲游浏览器怎么翻译网页

  步骤一:没有傲游浏览器的童鞋 步骤二:点开下拉====勾选"翻译". 步骤三:输入你想要的翻译的网址,选定你想翻译的内容 步骤四:耐心等待翻译结果

Word 2010中的“翻译字典”

  1.打开一篇文字文档,并且里面与你有需要翻译的文字,例如,我们这里先选择一篇中文散文; 2.在功能区点击"审阅"选项卡,选择"语言"区域的"翻译"选项组,单击"翻译所选文字"; 3.单击"审阅"功能卡,点击"语言"区域的"翻译"选项组,在弹出的下拉菜单中选择"选择转换语言"; 4.此时窗口会弹出一个"翻译语言选项"的对话框,

Word每一页的左边显示英语右边显示中文翻译

  现在,您想实现的效果是,在每一页里面,左边是英文,右边是对应的翻译好的中文.像这样的排版方式,可以方便我们更好的学习英语. ①使用分栏的是不科学的 要解决这个问题,很多人第一时间就会想到分栏,想把英文放在栏的左边,中文放在栏的右边.然而,这是可行的,却是不科学的. 因为,使用Word里面的自动分栏,原文英文和翻译后的中文,很难一一对应,造成学习上的困难.另外,如果您想再排版实现一一对应,那么,难度是非常大. ②使用文本框也是不合理的 以上方法难以实现.很多人会想到使用文本框的办法. 即在Wo

360浏览器如何翻译英文网页

  整个网页翻译: 1.打开360浏览器,在浏览器中打开你想浏览的英文网站,选择浏览器上面的翻译三角符号. 2.选择第一项,翻译当前网页,就会开始翻译了. 3.翻译完后,就可以看到全部是中文了. 单个句子翻译: 1.同样选择浏览器上面的翻译,选择第二项翻译文字. 2.在弹出的翻译对话框中,将要翻译的英文复制到文本框中,点击下面的翻译. 3.翻译完后,翻译的结果就在下面了,很方便的.