这可能有点混乱,所以如果它只是评论,我会尝试重新表达它。
我有两个ViewControllers (ViewController和Page2ViewController)。我让AVFoundation框架工作,举个例子,我就是这么做的:
//In ViewController.m
[PlaySound1 play];
[PlaySound2 play];
//In Page2ViewController.m
[PlaySound3 play];
[PlaySound4 play];每个ViewController都有一个停止函数,如下所示:
-(void)Stop{
[PlaySound1 stop];
[PlaySound2 stop];
[PlaySound3 stop];
[PlaySound4 stop];
PlaySound1.currentTime = 0.0;
PlaySound2.currentTime = 0.0;
PlaySound3.currentTime = 0.0;
PlaySound4.currentTime = 0.0;当你按下一个按钮时,它会使用停止功能并播放声音。我的问题是每个ViewController只会停止他们持有的音轨。我已经尝试将ViewControllers导入到彼此中,我已经尝试复制所有代码来将它们链接到每个ViewController中的文件,但也不起作用。
有什么想法吗?
谢谢。
发布于 2015-12-23 20:45:31
您确实希望在BOOL变量上检查此示例。这样,您还可以发送一个ViewController实例并调用它们的方法:
链接:
要将BOOL值从ViewControllerA传递给ViewControllerB,我们将执行以下操作。
在ViewControllerB.h中为BOOL创建一个属性
@property(非原子) BOOL *isSomethingEnabled;在ViewControllerA中,您需要告诉它有关ViewControllerB的信息,因此请使用
#import "ViewControllerB.h"然后你想要加载视图的地方,例如。didSelectRowAtIndex或某些IBAction在将其推送到nav堆栈之前,您需要在ViewControllerB中设置该属性。
ViewControllerB *viewControllerB = [[ViewControllerB alloc] initWithNib:@"ViewControllerB" bundle:nil];
viewControllerB.isSomethingEnabled = YES;
[self pushViewController:viewControllerB animated:YES];这会将ViewControllerB中的isSomethingEnabled设置为BOOL值YES。
https://stackoverflow.com/questions/34435691
复制相似问题