开发者社区 问答 正文

oc中在image view的view中添加一个textfield,textfield不能编辑?

UIImageView *person = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"geren"]];
 person.frame = CGRectMake(10, 10, 300, 130);
 UITextField *newPwd = [[UITextField alloc] initWithFrame:CGRectMake(95, 55, 185, 21)];
 newPwd.borderStyle = UITextBorderStyleRoundedRect;
 newPwd.autocorrectionType = UITextAutocorrectionTypeYes;
 newPwd.placeholder = @"输入您的新密码";
 newPwd.secureTextEntry = YES;
 newPwd.returnKeyType = UIReturnKeyDone;
 newPwd.clearButtonMode = UITextFieldViewModeWhileEditing;
 [newPwd setBackgroundColor:[UIColor whiteColor]];
 [person addSubview:newPwd];

展开
收起
爵霸 2016-03-10 18:02:49 1929 分享 版权
1 条回答
写回答
取消 提交回答
  • VIEW默认是不和用户交互的,所以要开启交互.userActivityEnable = YES

    2019-07-17 18:58:06
    赞同 展开评论
问答地址: