Memory leak every time UIScrollView is released

后端 未结 4 886
误落风尘
误落风尘 2020-12-01 18:22

In my app I have a scroll view and four table views. Each time one is dragged and then released, I get a 48 byte leak. This really adds up. As you can see, both groups of le

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-01 18:40

    Workaround: I found that the memory leak occurred in handlePan: if the UIScrollView delegate is set. I needed the delegate methods, so I subclassed UIScrollView, and declared my own @protocol. Then I overrode the target selector for the scrollView panGestureRecognizer, without sending it to super:

    //yourScrollView.h
    @protocol yourScrollViewDelegate
    -(void)yourProtocol;
    @end
    
    //yourScrollView.m
    -(void)handlePan:(id)sender{
       [yourDelegate yourProtocol];
    }
    

提交回复
热议问题