我正在设置一个ViewController演示版本的背景图像。购买或购买在应用程序购买中使用的东西,我想改变背景图像。
背景图像在ViewController1.m和应用程序购买在ViewController2.m中。
如何将值从ViewController2.m传递给ViewController1.m以更改背景图像。
发布于 2014-04-25 07:38:11
在购买后,在viewcontroller2中设置一个用户默认值。然后在viewcontroller1中检查这个值并进行相应的更新。
发布于 2014-04-25 07:41:52
使用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];发布于 2014-04-25 07:40:20
下面是在viewController之间传递值的示例。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
ShareMeU *destVieController = segue.destinationViewController;
destVieController.backgorndImageName =@"image.png"
}您可以在viewDidLoad方法中获得这个值。
https://stackoverflow.com/questions/23286895
复制相似问题