Звук кнопки iphone SDK - PullRequest
       3

Звук кнопки iphone SDK

0 голосов
/ 10 февраля 2011

Я хочу добавить звук к кнопке, пожалуйста, помогите мне с этим.

Ответы [ 3 ]

1 голос
/ 10 февраля 2011

Вы можете использовать метод - (void)playInputClick, найденный в классе UIDevice.Вы можете получить доступ к экземпляру этого класса, используя статический метод + (UIDevice *)currentDevice.Используйте этот метод для привязки входного звука по умолчанию к вашему собственному пользовательскому интерфейсу.

0 голосов
/ 10 февраля 2011
 - (IBAction)startPlayback:(UIButton *)sender {
       
           NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
           resourcePath = [resourcePath stringByAppendingString:@"/grabbag.m4a"];
           NSLog(@"Path to play: %@", resourcePath);
           NSError* err;

         
           player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:resourcePath] error:&err];

           if( err ){
               //bail!
               NSLog(@"Failed with reason: %@", [err localizedDescription]);
           }
           else{
               player.delegate = self;
               [player play];
           }
       
     }
0 голосов
/ 10 февраля 2011
- (IBAction)startPlayback:(UIButton *)sender {
   
       NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
       resourcePath = [resourcePath stringByAppendingString:@"/grabbag.m4a"];
       NSLog(@"Path to play: %@", resourcePath);
       NSError* err;

     
       player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:resourcePath] error:&err];

       if( err ){
           //bail!
           NSLog(@"Failed with reason: %@", [err localizedDescription]);
       }
       else{
           player.delegate = self;
           [player play];
       }
   
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...