从添加新项目返回后,[tableview scrollToRowAtIndexPath:]之后的嵌套推送动画

时间:2014-03-12 04:35:24

标签: ios uitableview uinavigationcontroller scroll nsfetchedresultscontroller

我的应用程序有一个方法可以将新项目添加到表中(使用Core Data进行存储),该方法初始化新对象,将其添加到Core Data,然后转到Edit视图。

在编辑视图中编辑并点击默认的“后退”按钮后,我在ViewDidAppear中执行以下操作,以便将我的表格滚动到新添加的项目:

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    // if a new event was just added then scroll the tableview to it
    if (_newlyAddedEvent != nil) {
        [self.eventListTable scrollToRowAtIndexPath:_newlyAddedEventIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
        _newlyAddedEvent = nil;
    }
    // dismiss the progress HUD
    [SVProgressHUD dismiss];
}

代码执行并抛出以下两条日志消息:

nested push animation can result in corrupted navigation bar

Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.

当然,我的导航栏都搞砸了。

_newlyAddedEventcontrollerDidChangeContent的{​​{1}}方法中设置。

NSFetchedResultsController时NSFetchedResultsController的_newlyAddedEventIndexPath = newIndexPath;方法中的

didChangeObject

任何人都可以给我一个提示要解决的问题吗?

我尝试在type = NSFetchedResultsChangeInsert中添加[self.eventListTable setDelaysContentTouches:NO];,但没有帮助。

谢谢!

1 个答案:

答案 0 :(得分:0)

将此代码放入调度主队列:

dispatch_async(dispatch_get_main_queue(),
^{
     [self.eventListTable scrollToRowAtIndexPath:_newlyAddedEventIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
 });