我有一个 UIView,当我初始化它时,它已经保留了计数 2,我不明白为什么,因此我无法使用 removefromsuperview 删除它
视图控制器.h
@property (nonatomic, retain)FinalAlgView * drawView;
视图控制器.m
self.drawView =[[FinalAlgView alloc]init];
NSLog(@"the retain count 1 of drawView is %d", [self.drawView retainCount]);
//the retain count 1 of drawView is 2
[self.bookReader addSubview:self.drawView];
NSLog(@"the retain count 2 of drawView is %d", [self.drawView retainCount]);
//the retain count 2 of drawView is 3
[self.drawView release];
NSLog(@"the retain count 3 of drawView is %d", [self.drawView retainCount]);
//the retain count 3 of drawView is 2
[UIView animateWithDuration:0.2
animations:^{self.drawView.alpha = 0.0;}
completion:^(BOOL finished){ [self.drawView removeFromSuperview];
}];
//do not remove
我不使用 ARC