简体   繁体   English

为什么我的iPhone不振动?

[英]Why my iPhone not Vibrate?

I've try to use a Vibration when a cell from my UITableView is selected. 当我从UITableView中选择一个单元格时,我尝试使用“振动”。

In my didselectedRowAtIndexPath i've put this code: 在我的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];



}

But the iPhone not vibrate when I click on the cell. 但是当我单击单元格时,iPhone不会振动。 Soo Why? Why为什么? Somebody can help me? 有人可以帮助我吗?

Check your iPhone sound settings. 检查您的iPhone声音设置。 If vibration is disabled in Settings, iPhone won't vibrate at all, also if vibration is caused by apps. 如果在“设置”中禁用了振动,则iPhone根本不会振动,即使振动是由应用程序引起的。

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 如果您听到声音,则可能是您的iPhone或振动设置有问题

you can also try to put the line in the first line of your function. 您也可以尝试将行放在函数的第一行中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM