我在我的应用程序中使用CAShapeLayer
和UIBezierPath
。我有一个重新加载按钮。当我多次重新加载视图时,它给了我一个EXC_BAD_ACCESS
错误。这是我的代码:
self.layer.sublayers = nil;
NSInteger numOfDays = [self differenceBetweenTwoDatesFromDate:startDate toDate:endDate];
CGFloat widthOfComponent = numOfDays * dayWidth;
if (self.frame.size.width > widthOfComponent) {
DLog(@"%@",NSStringFromCGRect(self.frame))
widthOfComponent = self.frame.size.width - 2 * DIFFERENCE_FROM_ORIGIN;
dayWidth = widthOfComponent/numOfDays;
}
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, widthOfComponent, self.frame.size.height);
[self reloadData];
[super layoutSubviews];
当我将新框架传递给self.frame
.