开发者

Calling a method from another view in objective-c. (iphone sdk)

开发者 https://www.devze.com 2022-12-24 16:28 出处:网络
I am currently creating a multi-view game on the iPhone platform.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 th

I am currently creating a multi-view game on the iPhone platform. 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. The heading is in the programAppDelegate class.

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.

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.

I realize this might be a simple misunderstanding of the objective-c language but I cannot find any info on this issue. I am a recent convert from Java so I am trying to wrap my head around everything. Thank you for your tim开发者_C百科e!


"viewController undeclared" means the variable viewController cannot be found. The message you send to is irrelevant. Make sure viewController exists in that scope first.

(Do you mean self.viewController?)

0

精彩评论

暂无评论...
验证码 换一张
取 消