[翻译] 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 上面帮助我们改进.
请确保遵循我们的代码风格,然后添加一个新特性的测试样例.
[翻译] VENCalculatorInputView的更多相关文章
- 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...
- 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...
- [翻译]开发文档:android Bitmap的高效使用
内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...
- 【探索】机器指令翻译成 JavaScript
前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...
- 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...
- 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...
- 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...
- 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?
0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点
在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...
随机推荐
- android学习-Toast的延迟时间
一般显示Toast都是一条语句够了 Toast.makeText(Context context, CharSequence text, int duration) Context是要显示Toast的 ...
- C和C++结构体的区别
C的结构体内不允许有函数存在,C++允许有内部成员函数,且允许该函数是虚函数.所以C的结构体是没有构造函数.析构函数.和this指针的. C的结构体对内部成员变量的访问权限只能是public,而C++ ...
- APP消息推送机制的实现(PUSH)
出于好奇,想了解一下消息推送机制,在网上搜索到了几篇文章,感觉还不错,粘贴下来,等真正用到的时候再仔细研究 以下两篇是关于ios的 1.http://blog.csdn.net/xyxjn/artic ...
- Extjs相关知识点梳理
store是一个为Ext器件提供record对象的存储容器,行为和属性都很象数据表 方法:不列举继承来的方法 Store( Object config ) 构造,config定义为{ autoLo ...
- vue权限路由实现方式总结二
之前已经写过一篇关于vue权限路由实现方式总结的文章,经过一段时间的踩坑和总结,下面说说目前我认为比较"完美"的一种方案:菜单与路由完全由后端提供. 菜单与路由完全由后端返回 这种 ...
- 一次单核CPU占用过高问题的处理
客户现场反馈,top的检查结果中,一个CPU的占用一直是100%.实际上现场有4个CPU,而且这个服务器是mysql专属服务器. 我的第一反应是io_thread一类的参数设置有问题,检查以后发现re ...
- JDBC使用DBUtils
1.commons-dbutils commons-dbutils 是 Apache 组织提供的一个开源 JDBC工具类库,它是对JDBC的简单封装,学习成本极低,并且使用dbutils能极大简化jd ...
- golang chan 发送接收测试数据
测试代码: package main import ( "fmt" "time" ) const ( num = 10000000 / ...
- 【java基础】 == 和 equals() 的区别
==号和equals()方法都是比较是否相等的方法,那它们有什么区别和联系呢? 首先,==号在比较基本数据类型(指的值类型)时比较的是值,而用==号比较两个对象时比较的是两个对象的地址值: int x ...
- 解决win7无法打开chm格式文件的问题
解决win7无法打开chm格式文件的问题. (一).简单方法(本人用的这个) 1.打开chm2.win7提示安全问题3.chm无法显示内容4.关闭chm5.右键点击chm,点击“解除锁定”,ok 没 ...