0
我想在更改後重新加載(刷新)我的mainviewcontroller。我將一些數據添加到數據模型,並在保存操作後,我將按鈕放在我的主視圖上的數據元素上。在第二個控制器中,我製作了一個版本部分,用於更改或刪除基本數據。我的問題是:如何在從基礎元素中解構元素後重新加載主視圖。我創建按鈕的代碼是在mainviewcontroller:更改後刷新mainviewController objective-c
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);
當我在主視圖中再次啓動應用程序時,應該只有它的圖標。 – virtualer007 2012-07-20 08:01:03