首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AVFoundation停止

AVFoundation停止
EN

Stack Overflow用户
提问于 2015-12-23 20:25:43
回答 1查看 44关注 0票数 0

这可能有点混乱,所以如果它只是评论,我会尝试重新表达它。

我有两个ViewControllers (ViewController和Page2ViewController)。我让AVFoundation框架工作,举个例子,我就是这么做的:

代码语言:javascript
复制
//In ViewController.m
[PlaySound1 play];
[PlaySound2 play];

//In Page2ViewController.m
[PlaySound3 play];
[PlaySound4 play];

每个ViewController都有一个停止函数,如下所示:

代码语言:javascript
复制
-(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中的文件,但也不起作用。

有什么想法吗?

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2015-12-23 20:45:31

您确实希望在BOOL变量上检查此示例。这样,您还可以发送一个ViewController实例并调用它们的方法:

链接:

要将BOOL值从ViewControllerA传递给ViewControllerB,我们将执行以下操作。

在ViewControllerB.h中为BOOL创建一个属性

@property(非原子) BOOL *isSomethingEnabled;在ViewControllerA中,您需要告诉它有关ViewControllerB的信息,因此请使用

代码语言:javascript
复制
#import "ViewControllerB.h"

然后你想要加载视图的地方,例如。didSelectRowAtIndex或某些IBAction在将其推送到nav堆栈之前,您需要在ViewControllerB中设置该属性。

代码语言:javascript
复制
ViewControllerB *viewControllerB = [[ViewControllerB alloc] initWithNib:@"ViewControllerB" bundle:nil];
viewControllerB.isSomethingEnabled = YES;
[self pushViewController:viewControllerB animated:YES];

这会将ViewControllerB中的isSomethingEnabled设置为BOOL值YES。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34435691

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档