Pergunta

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.

Foi útil?

Solução 2

Set a value in userdefaults in viewcontroller2 after purchasing. Then check this value in viewcontroller1 and update accordingly.

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top