我的代码在这里:
(instancetype)initWithFrame:(CGRect)frame
{
self = [[[NSBundle mainBundle] loadNibNamed:@"LSCouponADView" owner:Nil options:nil] objectAtIndex:0];
if (self) {
}
return self;
}
然后xcode有警告
Designated initializer missing a super call to designated initializer of the super class
当我构建它时。
最佳答案
您需要在此方法中添加这一行。
self = [super initWithFrame:frame];
if(self) {
}
return self;
来自 Apple Doc .
指定初始化器
The initializer of a class that takes the full complement of initialization parameters is usually the designated initializer. The designated initializer of a subclass must invoke the designated initializer of its superclass by sending a message to super. The convenience (or secondary) initializers—which can include init—do not call super. Instead they call (through a message to self) the initializer in the series with the next most parameters, supplying a default value for the parameter not passed into it. The final initializer in this series is the designated initializer.
关于ios - 指定初始化程序缺少对父类(super class)的指定初始化程序的 super 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37434601/