2012-03-01 40 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 2012-03-02 07:22:48

+0

感謝Aleksejs現在的工作! – WalterFantauzzi 2012-03-02 08:34:48

+0

@RyoSeaba不要忘記接受正確的答案! :) – 2012-03-02 09:24:02