无法动态生成UITextField以替换UILabel? [英] Unable to Generate UITextField dynamically in place of UILabel?

查看:135
本文介绍了无法动态生成UITextField以替换UILabel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想动态生成UITextField替换UILabel。
现在我想更新该数据。
我在数据库中显示UILabel中的数据,有一个UIButton用于编辑。
当我点击UIButton UITextField应该生成UILabel的位置,而且数据应该显示在UITextField。

I am trying to generate UITextField dynamically in place of UILabel. Now i want to update that data. I am displaying data in the UILabel from the database and there is an UIButton for editing. When i click on that UIButton UITextField should be generated in place of UILabel and also data should be displayed in UITextField.

推荐答案

你可以做的是设计一个视图与所有textfield工作在两种模式,首先readonly(通过设置userInteraction假)和第二编辑模式。这样可以避免使用标签。这将只需要一个所有字段的编辑按钮。如果你仍然想要坚持你的方法,你可以隐藏标签,使用他们的框架在他们的地方创建文本字段,并使它们可见,只要你在编辑模式下工作。不要忘记使用

What you can do is to design a view with all textfield which works in two modes, first readonly (by setting userInteraction to false ) and second editing mode. This way you can avoid the use of labels. This will need only one edit button for all of the fields. if you still want to stick with your approach, you can hide the labels, use their frames to create textfields at their place and make them visible as long as you are working in edit mode. Don't forget to use

[self.view bringSubviewToFront:TEXT_FIELD];


e
使用我之前提到的方法管理编辑是轻松的,需要较少的努力。希望它有帮助

While you add them to your view. e Managing the editing with the approach I mentioned earlier is mor easy and require less efforts. Hope it helps

这篇关于无法动态生成UITextField以替换UILabel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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