从核心数据中取消Swift或Objective-C中的Modal View Controller后重绘VC

问题描述

我正在遵循我认为是允许用户在模式视图控制器中编辑内容的首选模式。当用户点击完成时,模式VC将被关闭。

但是,在取消模式VC之后,保留显示内容的原始VC,就不会从核心数据中更新内容。

将在视图中设置内容,但是,关闭模态VC似乎不会触发使用新数据更新屏幕。如果您执行其他操作然后返回,则屏幕会更新,因此正在进行更改。关闭modalVC后,不会重新绘制屏幕。

一旦取消模式,如何强制更新当前的VC?

提供用于设置托管对象中标签文本的VC代码

- (void)viewWillAppear:(BOOL)animated {    
    [super viewWillAppear:animated];
self.myLabel.text = self.dataItem.content;//where dataItem is a managedobject in Core Data
}

//这是启动modalVC的代码:

- (void) showEditVC:(id) sender
{  
    UIStoryboard *storyBoard = self.storyboard;    
    MyEditVC *editVC =
    [storyBoard instantiateViewControllerWithIdentifier:@"editvc"];    
editVC.item = _dataItem;
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController: editVC];   
    [self presentViewController:nav animated:YES completion:^{ 
    }]; 
}

退出模态的代码在Modal VC中,并通过点击DONE触发:

- (IBAction)cancel:(id)sender {
    // Dismiss View Controller
    [self dismissViewControllerAnimated:YES completion:nil];
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...