UITextField doesn't seem to be calling textFieldShouldBeginEditing
-
08-03-2021 - |
문제
I am trying to disable UITextField from opening the keyboard but I am having trouble
.h
#import <UIKit/UIKit.h>
@interface XXViewController : UIViewController <UITextFieldDelegate> {
IBOutlet UITextField* someTextField;
}
@property (nonatomic, retain) IBOutlet UITextField* someTextField;
@end
.m
@implementation XXViewController
@synthesize someTextField;
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
NSLog(@"Hello");
return NO;
}
...
I am sure this is a very simple problem. I have been searching for ages and couldn't find a solution
Thanks Advance
EDIT: NSLog isn't being called.
해결책
You need to do:
[someTextField setDelegate:self];
Because although your class can be a delegate you never set it as the delegate for the UITextField you are using.
제휴하지 않습니다 StackOverflow