我正在 ViewController 演示版本中设置背景图像。购买或使用应用内购买购买东西后,我想更改背景图像。
ViewController1.m
中的背景图像以及 ViewController2.m
中的应用内购买。
如何将值从ViewController2.m
传递到ViewController1.m
以更改背景图像。
最佳答案
使用 NSNotificationCenter。在ViewController1.m的viewDidLoad中添加观察者
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeBackground) name:kChangeBGNotification object:nil];
在 -(void)changeBackground 方法中进行更改
在 ViewController2.m 中发布通知
[[NSNotificationCenter defaultCenter] postNotificationName:kChangeBGNotification object: managedObject];
关于ios - 购买后更换背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23286895/