ios - Getting Bad Access Error -
i using cashapelayer
, uibezierpath
in application. have reload button. when reloading view several times, giving me exc_bad_access
error. here code :
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];
i getting error when passing new frame self.frame
.
it's caused self.layer.sublayers = nil
. indiscriminately removing sublayers causes nasty crashes in ios 7, can occur later in program's execution. have tested thoroughly using both rootlayer.sublayers = nil
, [rootlayer.sublayers makeobjectsperformselector:@selector(removefromsuperlayer)]
. there must system-created layer that's getting messed up.
you have keep own array of layers , remove them yourself:
[myarrayoflayersiadded makeobjectsperformselector:@selector(removefromsuperlayer)];
Comments
Post a Comment