Blane Townsend
Blane Townsend

Reputation: 3038

Can a UIView be a UITextField Delegate

I am getting a sigabrt error when I try to set the delegate of my UITextField to my UIView class. I have used the UITextFieldDelgate Protocal. here is my code

    nameField = [[UILabel alloc] initWithFrame:CGRectMake(130, 40, 200, 30)];
    [nameField setDelegate:self];
    nameField.placeholder = @"<Game Name>";
    nameField.textAlignment = UITextAlignmentCenter;
    [self addSubview:nameField];

Upvotes: 0

Views: 689

Answers (1)

knuku
knuku

Reputation: 6102

You are about to use UITextField in constructor, not UILabel. Replace your first string with the following:

nameField = [[UITextField alloc] initWithFrame:CGRectMake(130, 40, 200, 30)];

Upvotes: 2

Related Questions