This crash occurs basically because of the switch of the child View controller, which is the code:
Transitionfromviewcontroller:toviewcontroller:
And basically because Fromviewcontroller and Toviewcontroller are the same viewcontroller, causing unbalanced
, most of the scenes are due to the addition of Segmentcontrol, which controls the switch of the sub-view. The following is the sample code:
-(void) ItemChange: (Uisegmentedcontrol *) Sender {
Switch (sender.selectedsegmentindex) {
Case 0:
{
[Self REPLACEFROMOLDVIEWCONTROLLER:CURRENTVC TONEWVIEWCONTROLLER:TASKVC];
}
Break
Case 1:
{
[Self REPLACEFROMOLDVIEWCONTROLLER:CURRENTVC tonewviewcontroller:classvc];
}
Break
Case 2:
{
[Self REPLACEFROMOLDVIEWCONTROLLER:CURRENTVC TONEWVIEWCONTROLLER:WEAKVC];
}
Break
Default
Break
}
}
-(void) Replacefromoldviewcontroller: (Uiviewcontroller *) OLDVC Tonewviewcontroller: (Uiviewcontroller *) newVc{
if (CURRENTVC = = NEWVC) {//To resolve the above problem
Return
}
if (NEWVC! = nil) {
[Self ADDCHILDVIEWCONTROLLER:NEWVC];
[Self TRANSITIONFROMVIEWCONTROLLER:OLDVC toviewcontroller:newvc duration:0.1 options: Uiviewanimationoptiontransitioncrossdissolve Animations:nil completion:^ (BOOL finished) {
if (finished) {
[NEWVC didmovetoparentviewcontroller:self];
[OLDVC Willmovetoparentviewcontroller:nil];
[OLDVC Removefromparentviewcontroller];
CURRENTVC = NEWVC;
}else{
CURRENTVC = OLDVC;
}
}];
}
}
Unbalanced calls to begin/end appearance transitions for XXX