OGeek|极客世界-中国程序员成长平台

标题: ios - +load 方法没有在 iOS 中被调用? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 02:22
标题: ios - +load 方法没有在 iOS 中被调用?

我知道 +(void)load 方法在 ios 中甚至在 main 函数之前就被调用了。 在我的情况下,它只被 UIView 调用,而不是 UITextView。

在这里被调用:

@implementation UIView (SomeMethodSwizzling)
+(void)load{



}
@end

这里没有被更新。

@implementation UITextView (SomeMethodSwizzling)
+(void)load{

}
@end



Best Answer-推荐答案


通常的原因是您实际上并没有链接文件。最常见的原因是您没有直接使用其中声明的任何内容(有时您需要将 -objc 传递给链接器以修复该问题)。另一个原因是您刚刚忘记将文件添加到目标(我看到这种情况经常发生)。

关于ios - +load 方法没有在 iOS 中被调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26150989/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4