开发者

memory leak when using transition

开发者 https://www.devze.com 2023-01-16 15:49 出处:网络
i get a memory leak and crash when using this transition more then 7-8 times: -(IBAction)pan1:(id)sender{

i get a memory leak and crash when using this transition more then 7-8 times:

-(IBAction)pan1:(id)sender{

    CATransition *transition = [CATransition animation];
    transition.duration = 0.50;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    NSString *types[4] = {kCATransitionFade};
    int rnd = random() % 4;
    transition.type = types[rnd];
    transitioning = YES;
    transition.delegate = self;
    UIImage *image4 = [UIImage im开发者_运维百科ageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"pan_01_cross_0.png" ofType:nil]];
    pan_cross_0 = [[UIImageView alloc] initWithImage:image4];
    [panView.layer addAnimation:transition forKey:nil];
    [panView addSubview:pan_cross_0]; 
}


At least 1 memory leak I can see with pan_cross_0 if you run the pan method multiple times.

pan_cross_0 = [[UIImageView alloc] initWithImage:image4];

You alloc new image view into pan_cross_0 but not releasing it from the last time. I am not sure what cause crashes. I need more details at least

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号