我在一个项目实现了这个自定义类: https://github.com/wimagguc/ios-custom-alertview
但是Xcode中给出了“initWithParentView”已被弃用警告。
- (id)init
{
return [self initWithParentView:NULL];
}
我一直没能找到一个替代这种方法,而类的工作出色。 谁能告诉我如何禁止这种警告或者告诉我替代“initWithParentView”?
我在一个项目实现了这个自定义类: https://github.com/wimagguc/ios-custom-alertview
但是Xcode中给出了“initWithParentView”已被弃用警告。
- (id)init
{
return [self initWithParentView:NULL];
}
我一直没能找到一个替代这种方法,而类的工作出色。 谁能告诉我如何禁止这种警告或者告诉我替代“initWithParentView”?
请阅读更改说明它清楚地说,使用init方法
编辑:因为它会在无限循环使用[super init]
而不是[self init]
- (id)init
{
// return [self init];
return [super init];
}
它看起来像开发商标明这是不推荐使用,并使用init方法建议。 您可以编辑第三方库删除此属性或抑制它。 也许移动initWithParentView的内容到INIT将是图书馆的一个更好的定位。
/*!
DEPRECATED: Use the [CustomIOS7AlertView init] method without passing a parent view.
*/
- (id)initWithParentView: (UIView *)_parentView __attribute__ ((deprecated));
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void) methodUsingDeprecatedStuff {
//use deprecated stuff
}
#pragma clang diagnostic pop
这应该镇压。
那么,类的* .h告诉你该怎么做
/ *! 弃用:使用[CustomIOS7AlertView INIT]方法没有通过父视图。 * /
所以,如果你重写自定义类只使用
[self init];
其他使用
[[CustomIOS7AlertView alloc] init]