奥凯,我有问题,无法找到我做错的事情。
I have a UIVievController
with a view and some functions and stuff. One is to open (from a button in a actionsheet) another UIVeiwController
. Looks like this:
PersonalSettings *personalSettings;
-(IBAction) displaySettingsMenu:(id)sender
{
personalSettings = [[PersonalSettings alloc]
initWithNibName:@"PersonalSettings"
bundle:nil];
[self.view addSubview:personalSettings.view];
[SettingsSheet dismissWithClickedButtonIndex:0 animated:YES];
}
This works like a charm and I can make som updates in this view.
When I close this view all the settings are updated properly and the view disappears, but what I want to do is to reload the parent ViewController
(View?) so I can see the new settings I ve made. I have a void function for this in the parent, but how can I call it?
When the save-button is hit in the child ViewController
I remove the view with:
[self.view removeFromSuperview];
What I have to do from here is to call the update function from the child view for the parent view.
我发现这方面的一些法典,但“超级阶级”而不是“超级概貌”除外,因为超级概览没有出现在清单中。 类似:
[self.view removeFromSuperview];
MainViewController *Parent = (MainViewController *)self.superclass;
[Parent updateView];
是否有“魔mag”我可以说什么,如“母体观点”?
I hope I ve made the problem understandable. :)
EDIT:
Really thanks you gyus, i m closer now. I m not 100% sure how this delegate thing works (yet) but i m close to a solution. Actually, i realized don t even have to run a method, just update a label.
从儿童身上写成:
MainViewController* Parent = [[MainViewController alloc] init];
Parent.delegate = self;
Parent.TheLabel.text = @"foo";
......这并不奏效,即使它确实找到了标签和一切东西。 如果儿童试图这样做:
NSLog(@"Parent label: %@", Parent.TheLabel.text);
它标有“字面标签:(null)”。
But, however, i can reach the update function from the child now and it runs. The problem is that this function takes values from other labels (in the parent view) and this is where it crashes - they all say null when i run the function from the child. Even if their not. Any ideas why?