1

I've try to use a Vibration when a cell from my UITableView is selected.

In my didselectedRowAtIndexPath i've put this code:

    #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];



}

But the iPhone not vibrate when I click on the cell. Soo Why? Somebody can help me?

Manlio
  • 10,768
  • 9
  • 50
  • 79

2 Answers2

5

Check your iPhone sound settings. If vibration is disabled in Settings, iPhone won't vibrate at all, also if vibration is caused by apps.

Aleksejs Mjaliks
  • 8,647
  • 6
  • 38
  • 44
0

try to put this in your code:

AudioServicesPlaySystemSound (1005);

if it makes a sound your code works if it won't your code is wrong. if you hear the sound there is probably something wrong wit your iPhone or vibration settings

you can also try to put the line in the first line of your function.

Floris497
  • 1,406
  • 12
  • 18