Set a value in userdefaults in viewcontroller2 after purchasing. Then check this value in viewcontroller1 and update accordingly.
Change background image after purchased
-
09-07-2023 - |
Domanda
I am setting background image in a ViewController demo version. After purchase or Buy something using in app purchase, i want to change background image.
background image in ViewController1.m
and in app purchase in ViewController2.m
.
How to pass the value from ViewController2.m
to ViewController1.m
to change the background image.
Soluzione 2
Altri suggerimenti
Use NSNotificationCenter. add observer in ViewController1.m's viewDidLoad
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeBackground) name:kChangeBGNotification object:nil];
do the changes in -(void)changeBackground method
post the notification in ViewController2.m's
[[NSNotificationCenter defaultCenter] postNotificationName:kChangeBGNotification object: managedObject];
Here is example to pass values between viewController.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
ShareMeU *destVieController = segue.destinationViewController;
destVieController.backgorndImageName =@"image.png"
}
You can get this values in viewDidLoad
method.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow