ios - UICollisionBehavior memory leak -


i've run believe bug uicollisionbehavior in uikit. adding them array of uiviews leads memory leak. put simple demo project creates 10 animations of group of views falling gravity applied, , collision enclosing view's bounds. (code below.) leaks template in instruments reports 9 64-byte leak each run.

- (void)doanimation {     self.animatebutton.enabled = no;      cgfloat left = 12.0f;     nsmutablearray *items = [nsmutablearray new];      // set array of views , add them superview     while (left < self.view.bounds.size.width - 12.0f) {         uiview *view = [[uiview alloc] initwithframe:cgrectmake(left, 70, 32, 32)];         left += 34.0f;         [self.view addsubview:view];         view.backgroundcolor = [uicolor graycolor];         [items addobject:view];     }      // create gravitybehavior , initialize views array     uigravitybehavior *gravity = [[uigravitybehavior alloc] initwithitems:items];     [self.animator addbehavior:gravity];      // create collisionbehavior , initialize views array     uicollisionbehavior *collision = [[uicollisionbehavior alloc] initwithitems:items];     collision.translatesreferenceboundsintoboundary = yes;     [self.animator addbehavior:collision]; }  // uidynamicanimatordelegate method that's called when collision animation complete - (void)dynamicanimatordidpause:(uidynamicanimator *)animator {     // collision behavior in order access items loop below     uicollisionbehavior *behavior;     (uidynamicbehavior *onebehavior in animator.behaviors) {         if ([onebehavior iskindofclass:[uicollisionbehavior class]]) {             behavior = (uicollisionbehavior *)onebehavior;             break;         }     }      // reset uidynamicanimator property's behaviors next run     [self.animator removeallbehaviors];      self.dropcount++;      // remove subviews     (uiview *view in behavior.items) {          [view removefromsuperview];     }      // run animation again or break     if (self.dropcount < 10) {         [self doanimation];     } else {         self.animatebutton.enabled = yes;     } } 

i'd able implement collisions in app i'm working on, leak makes unusable. have tried saving collisionbehavior in property , reusing it. prevents leaking 1 64-byte chunk of memory, collisions no longer work when that's done. can suggest workaround works?

i ran same issue fixed memory leak setting boundaries using uicollisionbehavior's

addboundarywithidentifier 

unfortunately setting boundaries translatesreferenceboundsintoboundary , settranslatesreferenceboundsintoboundarywithinsets caused leaks me.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -