変更後に mainviewcontroller をリロード (更新) したい。データモデルにいくつかのデータを追加し、操作を保存した後、メインビューのデータ要素にボタンを配置しました。2 番目のコントローラーでは、ベースからデータを変更または削除する編集セクションを作成します。私の質問は次のとおりです。要素をベースから削除した後、メインビューをリロードするにはどうすればよいですか。ボタンを作成するための私のコードは mainviewcontroller にあります:
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Destination" inManagedObjectContext:_managedObjectContext];
[request setEntity:entity];
NSError *error = nil;
mutableFetchResults = [[_managedObjectContext executeFetchRequest:request error:&error] mutableCopy];
CGFloat y = 130.;
for (int i = 0; i < [mutableFetchResults count]; i++) {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"ikonki%d.png",i]] forState:UIControlStateNormal];
[button setTitle:@"Test" forState:UIControlStateNormal];
NSLog(@"%@",_destination3.nazwa);
[button setTitleColor: [UIColor whiteColor] forState: UIControlStateNormal];
[button setEnabled:YES];
[button addTarget:self
action:@selector(buttonHandler:)
forControlEvents:UIControlEventTouchUpInside];
button.tag = i;
button.frame = CGRectMake(x, y, 64 , 64);