添加UITextField冻结应用程序

时间:2015-08-11 16:14:23

标签: ios objective-c

我正在尝试使用以下代码将UITextField添加到我的应用中的视图控制器:

passTextField = [[UITextField alloc] initWithFrame:CGRectMake(30, CGRectGetMaxY(userTextField.frame)+20, self.view.frame.size.width-60, 30)];
passTextField.placeholder = @"Password";
passTextField.textColor = [UIColor darkGrayColor];
passTextField.backgroundColor = [UIColor whiteColor];
passTextField.layer.borderWidth = 1.0f;
passTextField.layer.borderColor = [[UIColor lightGrayColor] CGColor];
passTextField.leftView = paddingView;
passTextField.leftViewMode = UITextFieldViewModeAlways;
passTextField.layer.cornerRadius = 4.0f;
passTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
passTextField.secureTextEntry = YES;
passTextField.delegate = self;
[scrollView addSubview:passTextField];

整个应用程序工作正常,但一旦它尝试加载包含上面提到的'passTextField'的视图,整个应用程序冻结迫使我,但要杀死它。

我做错了什么?我知道这很傻。

1 个答案:

答案 0 :(得分:1)

显然,我在同一视图中使用了我为另一个UITextField定义的paddingView,导致它进入无限循环。声明一个单独的paddingView解决了我的问题。