我想从视图控制器传递4 BOOL值到我的ChooseLevelVC:
if (_moves >=4) {
clvc.level1Completed3 = 1;
}
if (_moves == 3) {
clvc.level1Completed2 = 1;
}
if (_moves == 2) {
clvc.level1Completed1 = 1;
} else
clvc.level1Completed = 1;
但我不想提出ChooseLevelVC。它应该在Background中工作。此Bool值更改ChooseLevelVC中的按钮图像。
如果我将ChooseLevelVC用于:
,我的代码可以正常工作ChooseLevelViewController *clvc = [self.storyboard instantiateViewControllerWithIdentifier:@"chooseLevelViewController"];
if (_moves >=4) {
clvc.level1Completed3 = 1;
}
if (_moves == 3) {
clvc.level1Completed2 = 1;
}
if (_moves == 2) {
clvc.level1Completed1 = 1;
} else
clvc.level1Completed = 1;
[self presentViewController:clvc animated:NO completion:^(){
}];
如果我不提供ChooseLevelVC,则没有任何反应。我必须保存价值观吗?是的,怎么样?
谢谢!
答案 0 :(得分:0)
您需要将ChooseLevelViewController
存储在本地资产中:
@property (nonatomic, strong) ChooseLevelViewController *chooseLevelViewController;
...以便您可以在viewDidLoad
中 实例化:
- (void)viewDidLoad{
[super viewDidLoad];
// This is the only place you need to instantiate this view controller!
self.chooseLevelViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"chooseLevelViewController"];
}
...然后根据需要进行配置:
self.chooseLevelViewController.level1Completed1 = 1;
...最终随时展示:
[self presentViewController: self.chooseLevelViewController animated:NO];