Dynamic text fields in iPhone are possible or not?

故事扮演 提交于 2019-12-11 03:21:12

问题


I am trying to place textFields on iPhone screen dynamically but I am not getting an idea how to start it.

I have to place a textField where ever the user taps. when a user tap on screen a text field or textView should be places there and user can write a comment over there. Is it possible?


回答1:


Yes, it is indeed possible to add UITextField's to a screen dynamically.

A UITextField is just another view (albeit one that inherits from UIControl and then UIView). After you create a UITextView programatically, you can add it via addSubview to the view that is on screen.




回答2:


You could get the coordinates of where the touch happened. You could then dynamically create a textfield and set its origin in that coordinate.




回答3:


yes possible ..

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

is called on the view controller when user touches the view..

there you can allocate a textField and set its center to touch center.



来源:https://stackoverflow.com/questions/9480371/dynamic-text-fields-in-iphone-are-possible-or-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!