问题
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