[英]Calling a method from another view in objective-c. (iphone sdk)
I am currently creating a multi-view game on the iPhone platform. 我目前正在iPhone平台上创建多视图游戏。 I have my main view start to play some background music upon loading. 加载后,我的主视图开始播放一些背景音乐。 I then go to another view and start the game. 然后,我转到另一个视图并开始游戏。 I am trying to get the background music from the original view to stop once I start the game. 我试图从原始视图中获取背景音乐,以便在启动游戏后停止播放。 I am having trouble getting the stop playing music message to my original view. 我无法将停止播放音乐消息恢复到原始视图。 Here is the relevant info: 以下是相关信息:
The main view where the sound is played from is just a subView of the programViewController class called *viewController. 播放声音的主视图只是programViewController类的子视图,称为* viewController。 The heading is in the programAppDelegate class. 标题位于programAppDelegate类中。
The sound is done using the AVAudioPlayer class and plays fine when the program starts up and when I navigate to other subviews that are added on by going through the menu system. 声音是使用AVAudioPlayer类完成的,当程序启动时以及当我导航到通过菜单系统添加的其他子视图时,声音播放都很好。
In the view that I want to start the game, I attempt to call the instance of the class to turn of the player but anytime I use this format of code: 鉴于我想开始游戏,我尝试调用该类的实例来轮到玩家,但是只要我使用这种格式的代码,就可以:
[viewController #######];
It gives a build error of " viewController undeclared " no matter what I put after the "viewController" in the message.I have attempted to import the programAppDelegate.h file but it still gives the same error. 无论我在消息中的“ viewController”后面加上什么,它都将产生“ viewController undeclared ”的构建错误。我尝试导入programAppDelegate.h文件,但仍然会出现相同的错误。
I realize this might be a simple misunderstanding of the objective-c language but I cannot find any info on this issue. 我意识到这可能是对Objective-C语言的简单误解,但我找不到有关此问题的任何信息。 I am a recent convert from Java so I am trying to wrap my head around everything. 我是来自Java的最近的信奉者,所以我想尽一切办法。 Thank you for your time! 感谢您的时间!
" viewController undeclared " means the variable viewController
cannot be found. “ 未声明viewController ”表示找不到变量viewController
。 The message you send to is irrelevant. 您发送给的消息无关紧要。 Make sure viewController
exists in that scope first. 确保viewController
存在于该范围内。
(Do you mean self.viewController
?) (您是说self.viewController
吗?)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.