2012-03-01 9 views
1

私は、私のUITableViewのセルが選択されているときに振動を使用しようとしました。なぜ私のiPhoneは振動していないのですか?

私didselectedRowAtIndexPathでは、私はこのコードを入れている:

#pragma mark - DidselectRow 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

    //SPINNER 
    [spinner startAnimating]; 


    //[self performSelector:@selector(pushDetailView:) withObject:tableView afterDelay:0.1]; 

    int *riga = indexPath.row; 
    [NSThread detachNewThreadSelector:@selector(pushDetailView) toTarget:self withObject:riga]; 

    //////////////////////////////////////////////////////////////////////////////// 
    //       VIBRATION ALLERT         // 
    //////////////////////////////////////////////////////////////////////////////// 

    // Issue vibrate 
    //AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); 
    AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); 
    NSLog(@"Vibra?"); 
    //////////////////////////////////////////////////////////////////////////////// 
    //       VIBRATION ALLERT FIN        // 
    //////////////////////////////////////////////////////////////////////////////// 



    NSLog(@"Seleziono l'immagine: %@", [photoTitles objectAtIndex:indexPath.row]); 

    //creo un'istanza di DettaglioView 
    DettaglioView *dettaglioImmagine = [[DettaglioView alloc] initWithNibName:@"DettaglioView" bundle:nil]; 



    //Inseirsco il titolo nella Navigation BAR della vista 
    dettaglioImmagine.titoloSource = [photoTitles objectAtIndex:indexPath.row]; 

    dettaglioImmagine.imageCoverSource = [photoURLsLargeImage objectAtIndex:indexPath.row]; 
    NSLog(@"imageCoverSource: %@", dettaglioImmagine.imageCoverSource); 


    //passo alla vista del DettaglioView con l'animazione usando il pushViewController 
    [self.navigationController pushViewController:dettaglioImmagine animated:YES]; 


    //pulisco lo style della cella selezionata togliendo il fondino blu 
    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 



} 

をしかし、私は、セルをクリックするとiPhoneが振動しません。 Sooなぜですか? 誰かが私を助けることができますか?

答えて

0

はあなたのコードでこれを入れてみてください:

AudioServicesPlaySystemSound (1005); 

それはそれはあなたのコードが間違っていないかどう音、あなたのコードが動作になります。 音が聞こえる場合は、お使いのiPhoneの または振動設定

の間違いがあります。また、関数の最初の行に行を挿入することもできます。

5

iPhoneのサウンド設定を確認してください。設定で振動が無効になっていると、iPhoneが振動することはありません。

+0

こんにちはAleksejs Mjaliks ....それは本当です...振動は私のサウンド設定ではありませんでした。どうもありがとう。 – WalterFantauzzi

+0

Aleksejsさん、ありがとうございました! – WalterFantauzzi

+0

@RyoSeaba正解を受け入れることを忘れないでください! :) –

関連する問題