UITextField问题-输入附件和枚举 [英] UITextField questions - input accessory and enumeration

查看:63
本文介绍了UITextField问题-输入附件和枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用中,我有许多不同的功能。这些是视图控制器,它们都是我的自定义类Function的所有子类。通过对函数进行子类化,它们继承了背景图像或适当的导航按钮之类的标准内容。

In my app, I have many different functions. These are view controllers that are all subclasses of my custom class, Function. By subclassing function, they inherit standard things like a background image, or the appropriate nav buttons.

我的问题是,我可以在函数的viewDidLoad中放入一些代码,这将使它可以在子类的任何控制器中为UITextFields设置参数。因此,基本上可以使用某个类(在这种情况下为UITextField)来获得类的所有属性吗?

My question is, can I put some code in function's viewDidLoad, that will enable it to set parameters for UITextFields in any controller that subclasses it. So basically is it possible to get all the properties of a class with a certain class (in this case UITextField)?

我打算如何处理(除了标准化之外)键盘,设置代表等),是用来创建带有上一个和下一个按钮的UIToolbar,它会自动在文本字段之间切换(而不必为每个功能进行编码)。我知道您可以通过iOS模拟器中的文本字段进行枚举(通过按Tab键),但这是否是操作系统范围的事情?

What I intend to do with this (apart from standardising the keyboards, setting the delegate etc.), is to create a UIToolbar with previous and next buttons on, which automatically takes you between text fields (without having to code it for each function). I know you can enumerate through text fields in the iOS simulator (by pressing tab), but is this an OS-wide thing?

如果您可以通过文本字段进行枚举,我可以制作一个应用程序范围内的hideKeyboard方法和许多其他有用的东西...

Also if you could enumerate through text fields, I could make an app-wide hideKeyboard method and lots of other useful things...

在此先感谢您,我将不胜感激。

Thanks in advance, I would appreciate any advice.

推荐答案

您要在超类中实现 UITextFieldDelegate 。每个子类应负责创建文本字段的列表(NSArray)。一旦有了,就可以判断是否要离开最后一个文本字段,然后转到下一个控制器。

You want to implement the UITextFieldDelegate in your superclass. Each subclass should be responsible for creating a list (NSArray) of the text fields. Once you have that, you can tell if you are leaving the "last" text field, and go to the next controller.

如果要跳至在下一个字段中,您可以标记它们(或将它们保留在列表中)并使用委托方法和 becomeFirstResponder 来更改关键字段。

If you want to "tab" to the next field, you can tag them (or keep them in a list) and use the delegate methods and becomeFirstResponder to change the "key field".

这篇关于UITextField问题-输入附件和枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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