ios - 添加 UITextField 会卡住应用程序

标签 ios objective-c

我正在尝试使用以下代码将 UITextField 添加到我的应用程序中的 View Controller :

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”的 View ,整个应用程序就会卡住,迫使我不得不终止它。

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

最佳答案

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

关于ios - 添加 UITextField 会卡住应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31946895/

相关文章:

ios - Xcode 8 控制台垃圾?

iOS:如何确定 iCloud 中哪个文件较新(版本与上次修改日期)?

objective-c - UIImagePNGRepresentation 内存泄漏

iphone - addSubview : and insertSubview:atIndex:? 之间的区别

ios - 使用 sizeThatFits : doesn't work 调整 UIWebView 的大小

ios - 如何发布 One Signal 通知的附加数据并接收这些数据?

ios - 获取 NSMutableArray 中相同对象的索引

ios - Autoresizingmask 无法正常工作

iphone - 如何在所有子类初始化后执行操作?

objective-c - Xcode 奇怪的 ViewController 命名约定