【问题标题】:Why my iPhone not Vibrate?为什么我的 iPhone 不振动?
【发布时间】:2012-03-01 09:00:27
【问题描述】:

当我的 UITableView 中的一个单元格被选中时,我尝试使用振动。

在我的 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 没有振动。 苏为什么? 有人可以帮助我吗?

【问题讨论】:

    标签: objective-c ios vibration iphone-vibrate


    【解决方案1】:

    检查您的 iPhone 声音设置。如果在“设置”中禁用振动,iPhone 将完全不会振动,即使振动是由应用程序引起的。

    【讨论】:

    • 嗨 Aleksejs Mjaliks.... 这是真的...在我的声音设置中振动已关闭。非常感谢。
    【解决方案2】:

    尝试将其放入您的代码中:

    AudioServicesPlaySystemSound (1005);
    

    如果它发出声音,则您的代码可以正常工作,如果它不会,您的代码就是错误的。 如果您听到声音,您的 iPhone 可能有问题 或振动设置

    您也可以尝试将该行放在函数的第一行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-11
      • 2020-10-17
      • 1970-01-01
      • 2020-12-30
      • 1970-01-01
      相关资源
      最近更新 更多