【问题标题】:Application Crash while leaving UIViewController离开 UIViewController 时应用程序崩溃
【发布时间】:2017-06-27 04:59:30
【问题描述】:

离开UIViewController 时我的应用程序崩溃并出现以下错误。

【问题讨论】:

  • 将 tempCell 设置为强参考
  • @DSDharma 我设置了强属性,但它仍然会因 [FeedSingleViewCell 保留] 崩溃:消息发送到已释放实例 0x7fee13830600
  • 用强引用设置你的所有类属性。关键是内存被释放了。
  • 可以显示你的viewdidload和viewillappear代码
  • @Anbu.Karthik 我需要你兄弟澄清一下

标签: ios uitableview avplayer


【解决方案1】:

看起来您需要将以下代码添加到您的视图控制器类:

- (void)dealloc {
    currentCell = nil;
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

还要确保 currentCell 被声明为强或弱。

【讨论】:

  • 还是会崩溃
  • 您还需要取消订阅您单元格中的通知。添加 [[NSNotificationCenter defaultCenter] removeObserver:self];到单元格的 dealloc 和 prepareForReuse 方法。也不要忘记在这些方法中调用 removeTimeObserver
【解决方案2】:

您需要在 tableViewCell 的类中添加或更改。

这个崩溃可能是由于你的观察者仍然存在而发生的。所以你需要手动删除。

-(void)dealloc {
        @try {
            [self.playerItem removeObserver:self forKeyPath:@"playbackLikelyToKeepUp"];
            [self.playerItem removeObserver:self forKeyPath:@"rate"];
            self.playerItem = nil;
        }@catch(id anException) {
            NSLog(@"Trending Video Remove Observer Exception = %@", anException);
        }
    }

【讨论】:

    【解决方案3】:

    尝试删除委托属性,如下所示。

    -(void) viewWillDisappear:(BOOL) animated
    {  
       [super viewWillDisappear:animated];
       if ([self isMovingFromParentViewController])
       {
          if (self.navigationController.interactivePopGestureRecognizer.delegate == self)
          {
               self.navigationController.interactivePopGestureRecognizer.delegate = nil;
          }
       }
    }
    

    【讨论】:

    • 你看到我发布的问题和错误了吗?
    • 当然,当该控制器被释放但仍然是视图控制器的委托时,可能会发生崩溃。你试过这个吗?
    • 是的,试试这个,但我们的解决方案完全不同,我没有遇到这个问题。[FeedSingleViewCell 保留]:消息发送到已释放实例 0x7ffbb8950a00
    猜你喜欢
    • 2020-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-14
    相关资源
    最近更新 更多