当我尝试将UITextField的委托设置为我的UIView类时,我收到sigabrt错误。我使用过UITextFieldDelgate Protocal。这是我的代码
nameField = [[UILabel alloc] initWithFrame:CGRectMake(130, 40, 200, 30)];
[nameField setDelegate:self];
nameField.placeholder = @"<Game Name>";
nameField.textAlignment = UITextAlignmentCenter;
[self addSubview:nameField];
答案 0 :(得分:2)
您将在构造函数中使用UITextField
,而不是UILabel
。用以下内容替换您的第一个字符串:
nameField = [[UITextField alloc] initWithFrame:CGRectMake(130, 40, 200, 30)];