【问题标题】:Adding a sound to load with a spash screen in xcode在 xcode 中添加声音以加载启动画面
【发布时间】:2010-07-14 21:41:54
【问题描述】:

我为我的应用项目设置了启动画面,并希望在启动画面加载后播放声音 (mp3)。我是使用 xcode 的新手,想知道是否有人可以建议我需要输入什么代码/在哪里输入它..

非常感谢

【问题讨论】:

  • 对不起,这是一部 iPhone,我使用 'default.png' 作为初始屏幕
  • & 我的意思是标题中的“启动画面”——哦,我的眼睛很累 :-)

标签: xcode iphone-sdk-3.2 splash-screen


【解决方案1】:

您在第一个视图控制器中实现 yourintrosound.wav 系统声音,然后在加载视图控制器后使用 appDelegate 播放它:

在你的 firstViewController.h

@interface...

CFURLRef yourSound;
SystemSoundID   soundFileObject;

 @property (readwrite) CFURLRef yourSound;
 @property  SystemSoundID soundFileObject;

在你的 firstViewController.m viewDidLoad

NSURL *rightSound   = [[NSBundle mainBundle] URLForResource: @"yourintrosound" withExtension: @"wav"];
self.yourSound = (CFURLRef) [rightSound retain];
AudioServicesCreateSystemSoundID (yourSound, &soundFileObject);
[rightSound release];

在您的 AppDelegate.m 应用程序中:didFinishLaunchingWithOptions:

(就在 [window makeKeyAndVisible] 或您实现的任何初始屏幕显示之后)

 AudioServicesPlaySystemSound (firstViewController.soundFileObject);

别忘了 AudioToolbox 框架!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-02
    • 2021-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多