iOS 8 中的核心位置和 UITableView 性能问题
Core Location and UITableView performance issues in iOS 8
我有一个包含两个视图的视图控制器:一个使用 Google 地图 API 的 地图视图 和一个 UITableView。
视图控制器从 Google 地图中获取特定位置特定半径范围内的位置对象列表,并将它们绘制在地图视图上作为标记,UITableView
作为 UITableViewCell
s.
然后用户可以点击按钮在这两个视图之间转换。
这在 iOS 7 中运行非常顺利。但是在 iOS 8 中,如果我通过在我的 .plist 中设置请求权限键值对(NSLocationWhenInUseUsageDescription
在我的例子中)来请求用户的位置权限,当我从地图视图转换到 UITableView 时有明显的滞后,并且在尝试滚动 UITableView
.
时也有滞后
只要我删除 .plist 中的 NSLocationWhenInUseUsageDescription
键,它就可以正常工作。
我尝试删除所有单元格配置,但即使加载 UITableView
没有单元格也存在延迟。
这是我删除所有单元格配置后的 tableView:cellForRowAtIndexPath
方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyTableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyTableCell" forIndexPath:indexPath];
if (!cell) {
cell = [[StoreCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyTableCell"];
}
return cell;
}
有没有人遇到过类似的问题?我想知道这是否是 iOS 8.
中的错误
抱歉冗长 post,但只想尽可能详尽。
谢谢!!
解决了问题。事实证明,我从未阻止 locationManager 更新当前用户位置,因此 didUpdateLocations
委托方法不断被调用并消耗资源。一旦我将 stopUpdatingLocation
方法发送给位置管理器,它就解决了问题
我有一个包含两个视图的视图控制器:一个使用 Google 地图 API 的 地图视图 和一个 UITableView。
视图控制器从 Google 地图中获取特定位置特定半径范围内的位置对象列表,并将它们绘制在地图视图上作为标记,UITableView
作为 UITableViewCell
s.
然后用户可以点击按钮在这两个视图之间转换。
这在 iOS 7 中运行非常顺利。但是在 iOS 8 中,如果我通过在我的 .plist 中设置请求权限键值对(NSLocationWhenInUseUsageDescription
在我的例子中)来请求用户的位置权限,当我从地图视图转换到 UITableView 时有明显的滞后,并且在尝试滚动 UITableView
.
只要我删除 .plist 中的 NSLocationWhenInUseUsageDescription
键,它就可以正常工作。
我尝试删除所有单元格配置,但即使加载 UITableView
没有单元格也存在延迟。
这是我删除所有单元格配置后的 tableView:cellForRowAtIndexPath
方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyTableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyTableCell" forIndexPath:indexPath];
if (!cell) {
cell = [[StoreCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyTableCell"];
}
return cell;
}
有没有人遇到过类似的问题?我想知道这是否是 iOS 8.
中的错误抱歉冗长 post,但只想尽可能详尽。
谢谢!!
解决了问题。事实证明,我从未阻止 locationManager 更新当前用户位置,因此 didUpdateLocations
委托方法不断被调用并消耗资源。一旦我将 stopUpdatingLocation
方法发送给位置管理器,它就解决了问题