【发布时间】:2010-08-17 22:01:26
【问题描述】:
我正在为 iphone 编写一个小应用程序(只是为了好玩)
我想要什么:
如果我按下“更新”按钮:
- 向服务器发送一些东西
- 解析服务器的答案
- 更新屏幕上部分标签的内容
- 显示答案
- 播放系统声音 //使用音频工具箱
- 睡几秒,刚好能完成之前的系统声音调用
- 做其他事情
- 结束
实际上,一切正常,但是...由于某种原因,标签内容在按下“更新”按钮时调用的方法/回调/函数结束时更新。
我做错了什么? 谢谢!
一些代码:
-(void) playASound: (NSString *) file {
//Get the filename of the sound file:
NSString *path = [NSString stringWithFormat:@"%@/%@",
[[NSBundle mainBundle] resourcePath],
file];
SystemSoundID soundID;
//Get a URL for the sound file
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
//play the file
AudioServicesPlaySystemSound(soundID);
}
- (IBAction)update: (id) sender{
BOOL error=[self sendContent];
if ( error == NO ){
result.text=[self parseContent];
[self playSound:@"ready"];
sleep(4);
....
}
// here is updated the gui
}
【问题讨论】:
标签: iphone objective-c iphone-sdk-3.0