Reputation: 156
I added a sub view from controller A. Now in controller B which is the subview controller, how can I reload view A when the user is done with B? My codes of adding subview:
ChangeProfileImage *changeProfileImage =[[ChangeProfileImage alloc] init];
changeProfileImage.modalPresentationStyle = UIModalPresentationFormSheet;
changeProfileImage.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
changeProfileImage.view.frame = CGRectMake(50, 50, 300, 300);
UIView *dimBackgroundView = [[UIView alloc] initWithFrame:self.view.bounds];
dimBackgroundView.backgroundColor = [[UIColor grayColor] colorWithAlphaComponent:.5f];
[self.view addSubview:dimBackgroundView];
[self.view addSubview:changeProfileImage.view];
Upvotes: 0
Views: 797
Reputation: 6160
you can set a tag for "dimbackground" .. and remove it like this:
dimBackgroundView.tag = 111;//you will do this line when you create the view.
UIView *view = [controllerA.view viewWithTag:111];
[view removeFromSuperview];
To Refresh your viewController :
when the user click the submit button and you remove the B view .. post a notification using NSNotificationCenter
like this :
[[NSNotificationCenter defaultCenter] postNotificationName:@"UserSubmit" object:nil];
and in controllerA .. viewDidLoad For example add it as observer like this
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshView) name:@"UserSubmit" object:nil];
and you will implement this function :
- (void) refreshView
{
//Do your stuff
}
Upvotes: 1
Reputation: 1965
create a button on viewcontroller B with IBAction Connected to it,write the below code in the IBaction of that button,This will remove viewcontroller B
[self.view removeFromSuperview];
Upvotes: 0