문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top