【发布时间】:2016-02-17 13:17:08
【问题描述】:
有效的是,应用程序会在位置发生重大变化时启动到后台。在AppDelegate 中,我检查UIApplicationLaunchOptionsLocationKey 并初始化位置管理器:
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters
locationManager.distanceFilter = 50
locationManager.allowsBackgroundLocationUpdates = true
locationManager.startMonitoringSignificantLocationChanges()
初始视图控制器是UITabBarController,它显示UICollectionViewController。
当我设置 UICollectionView 中没有单元格时,一切正常,locationManager 的 didUpdateLocations 被调用。
但是,当 UICollectionView 的 numberOfItemsInSection 返回 1 时,didUpdateLocations 不会被调用。相反,UICollectionView 的 CPU 使用率为 99%,持续几分钟,直到应用崩溃。
我从单元格中删除了所有控件和所有代码,所以它现在是一个空单元格,但仍然会发生这种情况。
在 Time Profiler 中,我发现这与 UICollectionViewData setLayoutAttributes 有关。
这里有什么问题?
更新一:setLayoutAttributes下有栈。
更新 2:应用运行良好,用户正常启动时从未崩溃。
【问题讨论】:
标签: uicollectionview uikit profiling core-location cllocationmanager