美文网首页
UIViewController退出不走dealloc

UIViewController退出不走dealloc

作者: kangomake | 来源:发表于2018-08-21 15:49 被阅读8次
    可能的原因:

    1.ViewController中存在NSTimer
    如果你的ViewController中有NSTimer,那么你就要注意了,因为当你调用

    [NSTimer scheduledTimerWithTimeInterval:1.0 
                                     target:self 
                                   selector:@selector(updateTime:) 
                                   userInfo:nil 
                                    repeats:YES];
    
    self.playerTimer = [NSTimerscheduledTimerWithTimeInterval:1target:selfselector:@selector(playProgressAction)userInfo:nilrepeats:YES];
    使用后记得销毁
      [_playerTimerinvalidate];
      _playerTimer =nil;
    
    

    2.协议delegate 应该使用weak修饰,否则会引起循环引用 不能释放内存
    @property (nonatomic,weak)id<ceshiDelegate>delegate;

    3.使用到block的地方,block回调中不能直接使用self 否则可能引起循环引用。

       __weaktypeof(self) weakSelf =self;
        _audioStream.onCompletion=^(){
            [weakSelf nextButtonAction];
        };
    

    相关文章

      网友评论

          本文标题:UIViewController退出不走dealloc

          本文链接:https://www.haomeiwen.com/subject/gtljiftx.html