本文将分享iOS9-“尝试删除并重新加载相同的索引路径”的详细内容,并且还将对尝试删除指定的数据元素时出错进行详尽解释,此外,我们还将为大家带来关于android–删除并重新添加后,接近警报触发两次、
本文将分享iOS 9-“尝试删除并重新加载相同的索引路径”的详细内容,并且还将对尝试删除指定的数据元素时出错进行详尽解释,此外,我们还将为大家带来关于android – 删除并重新添加后,接近警报触发两次、Angular2 Router 2.0.0是否在相同的URL加载了不同的参数时不重新加载组件?、angularjs – 角度重载当前路径并重新加载当前模板、Angular重新加载当前路线并重新加载当前模板的相关知识,希望对你有所帮助。
本文目录一览:- iOS 9-“尝试删除并重新加载相同的索引路径”(尝试删除指定的数据元素时出错)
- android – 删除并重新添加后,接近警报触发两次
- Angular2 Router 2.0.0是否在相同的URL加载了不同的参数时不重新加载组件?
- angularjs – 角度重载当前路径并重新加载当前模板
- Angular重新加载当前路线并重新加载当前模板
iOS 9-“尝试删除并重新加载相同的索引路径”(尝试删除指定的数据元素时出错)
这是一个错误:
CoreData:错误:严重的应用程序错误。在调用-
controllerDidChangeContent:期间,从NSFetchedResultsController的委托捕获了一个异常。尝试使用userInfo(null)删除并重新加载相同的索引路径({length
= 2,path = 0-0})
这是我的典型NSFetchedResultsControllerDelegate
:
func controllerWillChangeContent(controller: NSFetchedResultsController) { tableView.beginUpdates()}func controller(controller: NSFetchedResultsController, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType) { let indexSet = NSIndexSet(index: sectionIndex) switch type { case .Insert: tableView.insertSections(indexSet, withRowAnimation: .Fade) case .Delete: tableView.deleteSections(indexSet, withRowAnimation: .Fade) case .Update: fallthrough case .Move: tableView.reloadSections(indexSet, withRowAnimation: .Fade) }}func controller(controller: NSFetchedResultsController, didChangeObject anObject: NSManagedObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) { switch type { case .Insert: if let newIndexPath = newIndexPath { tableView.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: .Fade) } case .Delete: if let indexPath = indexPath { tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) } case .Update: if let indexPath = indexPath { tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .None) } case .Move: if let indexPath = indexPath { if let newIndexPath = newIndexPath { tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) tableView.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: .Fade) } } }}func controllerDidChangeContent(controller: NSFetchedResultsController) { tableView.endUpdates()}
在viewDidLoad()
:
private func setupOnceFetchedResultsController() { if fetchedResultsController == nil { let context = NSManagedObjectContext.MR_defaultContext() let fetchReguest = NSFetchRequest(entityName: "DBOrder") let dateDescriptor = NSSortDescriptor(key: "date", ascending: false) fetchReguest.predicate = NSPredicate(format: "user.identifier = %@", DBAppSettings.currentUser!.identifier ) fetchReguest.sortDescriptors = [dateDescriptor] fetchReguest.fetchLimit = 10 fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchReguest, managedObjectContext: context, sectionNameKeyPath: "identifier", cacheName: nil) fetchedResultsController.delegate = self try! fetchedResultsController.performFetch() }}
答案1
小编典典由于某种原因,先NSFetchedResultsController
调用.Update
后跟.Move
aftercontrollerWillChangeContent:
。
看起来就像这样: BEGIN UPDATES- > UPDATE- > MOVE- > END UPDATES 。
仅在iOS 8.x下发生
在一次更新会话期间,将重新加载和删除同一单元格,从而导致崩溃。
最简单的修复方法:
代码的以下部分:
case .Update: if let indexPath = indexPath { tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) }
用。。。来代替:
case .Update: if let indexPath = indexPath { // 1. get your cell // 2. get object related to your cell from fetched results controller // 3. update your cell using that object //EXAMPLE: if let cell = tableView.cellForRowAtIndexPath(indexPath) as? WLTableViewCell { //1 let wishlist = fetchedResultsController.objectAtIndexPath(indexPath) as! WLWishlist //2 cell.configureCellWithWishlist(wishlist) //3 } }
确实有效 。
android – 删除并重新添加后,接近警报触发两次
这是我用来删除近距离警报的代码:
private void removeProximityAlert(int id) { final LocationManager manager = (LocationManager) getSystemService( Context.LOCATION_SERVICE ); Intent intent = new Intent(PROX_ALERT_INTENT + id); PendingIntent proximityIntent = PendingIntent.getbroadcast(this,id,intent,PendingIntent.FLAG_CANCEL_CURRENT); manager.removeProximityAlert(proximityIntent); }
这是我用来添加接近警报的代码:
private void addProximityAlert(double latitude,double longitude,int id,int radius,String title) { final LocationManager manager = (LocationManager) getSystemService( Context.LOCATION_SERVICE ); Intent intent = new Intent(PROX_ALERT_INTENT + id); PendingIntent proximityIntent = PendingIntent.getbroadcast(this,PendingIntent.FLAG_CANCEL_CURRENT); manager.addProximityAlert( latitude,longitude,radius,-1,proximityIntent ); IntentFilter filter = new IntentFilter(PROX_ALERT_INTENT + id); registerReceiver(new ProximityIntentReceiver(id,title),filter); }
解决方法
解析度:
在你的removeProximityAlert中,我会更改以下行
PendingIntent proximityIntent = PendingIntent.getbroadcast(this,PendingIntent.FLAG_CANCEL_CURRENT);
至:
PendingIntent proximityIntent = PendingIntent.getbroadcast(this,PendingIntent.FLAG_UPDATE_CURRENT).cancel();
FLAG_UPDATE_CURRENT返回创建的现有文件(如果有). cancel()应该为你处理剩下的事情.
编辑
如果我将cancel()分成一个单独的行,我不会得到任何错误.试试这个:
PendingIntent proximityIntent = PendingIntent.getbroadcast(this,PendingIntent.FLAG_UPDATE_CURRENT); proximityIntent.cancel();
Angular2 Router 2.0.0是否在相同的URL加载了不同的参数时不重新加载组件?
我的.routing.ts文件中有这个
export const routing = RouterModule.forChild([
{
path: 'page/:id',component: PageComponent
}]);
我的PageComponent
文件检查id参数并相应地加载数据。在路由器的早期版本中,如果我从/ page / 4转到/ page /
25,则该页面将“重新加载”并且组件将更新。
现在,当我尝试导航到/ page / X时,其中X是id,它只会第一次加载,然后url会更改,但是组件不会再次“重新加载”。
是否需要传递某些内容以强制重新加载组件并调用ngOnInit事件?
angularjs – 角度重载当前路径并重新加载当前模板
我要“修复”,但实际上我认为这样做是一个很好的用户体验,而不是处理返回url作为查询参数.
这个想法是一旦他们登录,我只想重新加载当前的路由,再次通过“/ profile”对配置文件partial进行GET请求,并将其重新切换而不是登录部分.
但是,我不能得到这个“重新加载当前路由”工作.我尝试了以下所有内容:
$location.$$compose(); $location.absUrl($location.path()); $location.url($location.path()); $location.path($location.path()) $route.reload();
但没有工作. $route.reload()似乎是确定的方式,但它也不起作用.它通过路由周期,重新控制控制器,但不执行GET请求来重新加载模板
唯一有效的是通过location.reload()进行硬刷新,但这不是理想的.
如何强制有角度重新加载当前路由的模板?
Templates are
cached,if a user does not have the permissions to be in a page,then
this check should be done before it reaches the controller or after,
within the controller,but not on the template retrievalIf this is the way you want to follow,then you need to remove the
template from the $templateCache before you call reload
所以这对我来说是有效的,因为登录模板实际上被缓存为用户试图访问的模板.所以删除它,并让角度重新获取当前路线正确的一个像一个魅力.
var currentPageTemplate = $route.current.templateUrl; $templateCache.remove(currentPageTemplate); $route.reload();
Angular重新加载当前路线并重新加载当前模板
当用户访问未经授权的个人页面(例如个人资料)时,我的后端302重定向到控制器操作,该操作代替部分个人资料来提供登录部分。由于它302重定向到返回部分操作的动作,因此URL地址栏与用户尝试访问的页面(“
/ profile”)没有变化。
我本来打算“修复”该问题,但实际上我认为它可以提供良好的用户体验,而不是将返回网址作为查询参数来处理。
想法是一旦他们登录,我只想重新加载当前路由,也可以通过“ / profile”对配置文件部分执行GET请求,然后将其切换回而不是登录部分。
但是,我无法使“重新加载当前路线”正常工作。我尝试了以下所有方法:
$location.$$compose();
$location.absUrl($location.path());
$location.url($location.path());
$location.path($location.path())
$route.reload();
但是没有任何作用。$ route.reload()似乎是确定的方法,但它也不起作用。它经历了路由周期,重新实例化了控制器,但不执行GET请求来重新加载模板
唯一有效的方法是强制刷新,location.reload()
但这并不理想。
如何强制angular重新加载当前路线的模板?
今天的关于iOS 9-“尝试删除并重新加载相同的索引路径”和尝试删除指定的数据元素时出错的分享已经结束,谢谢您的关注,如果想了解更多关于android – 删除并重新添加后,接近警报触发两次、Angular2 Router 2.0.0是否在相同的URL加载了不同的参数时不重新加载组件?、angularjs – 角度重载当前路径并重新加载当前模板、Angular重新加载当前路线并重新加载当前模板的相关知识,请在本站进行查询。
本文标签: