我有一个有 7 个孩子的 UIViewCustom 类。每个孩子都有自己的班级功能来帮助启动
+(int) minHeight;
+(int) minWidth;
在 UITableView 中,我选择其中一个类,然后调用函数“-insertNewObjectWithClassName:(NSString*)childClassName”。
在那个函数中,我想根据类名创建实例,所以我尝试了
Class *class = NSClassFromString(childClassName);
CGRect frame = CGRectMake(0, 0, [class minWidth], [class minWidth])
MotherClass *view = [[class alloc] initWithFrame:frame];
但不幸的是无法调用静态函数。
有没有办法让编译器说类不仅仅是一个类,还是一个 MotherClass 来告诉他函数?
非常感谢!
编辑:警告:语义问题:找不到方法“-minWidth”(返回类型默认为“id”)
解决方案:类 class 而不是 Class *class