Reputation: 4288
I am programatically adding a UITextField
into a UIImageView
. When I set the text property, I can see the text.
The issue is, it's not letting me input text into it like an input field when I run the app.
This is my code for initializing the TextField:
UITextField *textField = [[UITextField alloc] init];
textField.frame = CGRectMake(38.0f, 0.0f, self.view.frame.size.width - 38.0f, 40.0f);
textField.text = @"Hello";
textField.background = [[UIImage imageNamed: @"field.png"] stretchableImageWithLeftCapWidth:12 topCapHeight:19];
textField.backgroundColor = [UIColor whiteColor];
textField.userInteractionEnabled = YES;
[bar addSubview: textField];
Do I need to do something special to allow for text input?
Upvotes: 1
Views: 471
Reputation: 73
Text Field not added into imageview . You can add textfield on view,for user interaction enabled. First you can add imageview and then add text field on the view.
Like This--
[self.view addSubview:imgV];
[self.view addSubview: textField];
Upvotes: 0
Reputation: 2802
If bar is an UIImageView
, try to set
bar.userInteractionEnabled = TRUE;
Upvotes: 1