gpt4 book ai didi

ios - textFieldShouldBeginEditing 没有响应

转载 作者:行者123 更新时间:2023-11-28 22:22:13 25 4
gpt4 key购买 nike

#import <UIKit/UIKit.h>
#import "HZAreaPickerView.h"

@interface CodeNumberViewController : UIViewController<UITextFieldDelegate, HZAreaPickerDelegate>
@property (weak, nonatomic) IBOutlet UITextField *areaText;
@property (weak, nonatomic) IBOutlet UITextField *cityText;


@property (strong, nonatomic) NSString *areaValue, *cityValue;
@property (strong, nonatomic) HZAreaPickerView *locatePicker;

-(void)cancelLocatePicker;
@end

----------------下面的.m文件----------------

#pragma mark - TextField delegate
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
if ([textField isEqual:self.areaText]) {
[self cancelLocatePicker];
self.locatePicker = [[HZAreaPickerView alloc] initWithStyle:HZAreaPickerWithStateAndCityAndDistrict delegate:self];
[self.locatePicker showInView:self.view];
} else {
[self cancelLocatePicker];
self.locatePicker = [[HZAreaPickerView alloc] initWithStyle:HZAreaPickerWithStateAndCity delegate:self];
[self.locatePicker showInView:self.view];
}
return NO;
}

当我点击 UITextField 时,我发现 textFieldShouldBeginEditing 甚至没有被调用。怎么了?我已经将 UITextField 连接到 .h 文件。

我真的希望你能帮忙,如果你需要更多细节,我会补充,不要减去我的声誉,因为我没有太多。谢谢

最佳答案

我猜你没有在你的 viewDidLoad 集中设置委托(delegate):

self.areaText.delegate = self;

self.cityText.delegate = self;

关于ios - textFieldShouldBeginEditing 没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20029364/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com