所以我正在编写一个继承自 UIView 的自定义类。我有一堆子视图,我添加了。
所以遇到2个问题。如果我使超级视图和子视图引用强,则视图正在泄漏。如果我让他们变得虚弱,他们根本就不会出现。我究竟做错了什么?
自定义UIView
@interface CustomUIView : UIView
@property(nonatomic, strong) AnotherCustomUIView *mySubView;
@end
@implementation CustomUIView {
- (void)initCommon {
self.mySubView = [self createSubView]
}
- (AnotherCustomUIView *) createSubView {
return [[AnotherCustomUIView alloc] init:self];
}
@end
另一个CustomUIView
@interface AnotherCustomUIView : UIScrollView
@property (nonatomic, strong) CustomUIView *ownerView;
@end
@implementation AnotherCustomUIView
- (id)init:(CustomUIView *) ownerView {
self = [super init];
if (self) {
self.ownerView = ownerView;
self.delegate = self;
}
return self;
}
@end