gpt4 book ai didi

iphone - 我怎样才能摆脱这个警告?

转载 作者:太空狗 更新时间:2023-10-30 04:00:36 25 4
gpt4 key购买 nike

我在 (theTextField.delegate = self;) 行收到一条警告,上面写着“Assigning to 'id from incompatible type Alert Prompt”

- (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle okButtonTitle:(NSString *)okayButtonTitle
{

if (self == [super initWithTitle:title message:message delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:okayButtonTitle, nil])
{
UITextField *theTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[theTextField setBackgroundColor:[UIColor whiteColor]];
[self addSubview:theTextField];
self.textField = theTextField;
[theTextField release];
CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, -25.0);
[self setTransform:translate];

theTextField.backgroundColor = [UIColor clearColor];
theTextField.borderStyle = UITextBorderStyleRoundedRect;
theTextField.delegate = self;
}
return self;
}

最佳答案

关于此属性在 the docs

@property(nonatomic, assign) id<UITextFieldDelegate> delegate

这意味着,您的类必须符合UITextFieldDelegate 协议(protocol)。
声明可能看起来像这样

@interface MyController : NSObject <UITextFieldDelegate> {

关于iphone - 我怎样才能摆脱这个警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5769450/

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