Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UITableViewCell子类在选中时需要播放声音_Iphone_Ios4 - Fatal编程技术网

Iphone UITableViewCell子类在选中时需要播放声音

Iphone UITableViewCell子类在选中时需要播放声音,iphone,ios4,Iphone,Ios4,我有一个UITableViewCell子类,它出现在我的应用程序的几个表中,我希望它在被选中时能够播放声音效果。我知道如何播放声音(我已经在为按钮播放了),但我需要知道如何响应桌面单元格的触摸事件 设置表视图委托 实现方法-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(nsindepath*)indepath并在此方法中播放声音 设置表视图委托 实现方法-(void)tableView:(UITableView*

我有一个UITableViewCell子类,它出现在我的应用程序的几个表中,我希望它在被选中时能够播放声音效果。我知道如何播放声音(我已经在为按钮播放了),但我需要知道如何响应桌面单元格的触摸事件

  • 设置表视图委托
  • 实现方法-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(nsindepath*)indepath并在此方法中播放声音
  • 设置表视图委托
  • 实现方法-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(nsindepath*)indepath并在此方法中播放声音
  • 签出方法(在uitableviewcell子类中重写它)

    然后在您的子类中:

    - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
       [super setSelected:selected animated:animated];
       if (selected) {
           //TODO: play your sound here
       }
    }
    
    干杯, Pawel

    签出方法(在uitableviewcell子类中重写它)

    然后在您的子类中:

    - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
       [super setSelected:selected animated:animated];
       if (selected) {
           //TODO: play your sound here
       }
    }
    
    干杯,
    Pawel

    那么这不能在细胞内完成?必须在tableviewcontroller中完成?啊,对不起,现在我明白你为什么要在手机上完成了。您可能可以在单元格中重写setSelected方法,这样就不能在单元格中完成吗?必须在tableviewcontroller中完成?啊,对不起,现在我明白你为什么要在手机上完成了。您可以在单元格中重写setSelected方法