Iphone 如何禁用tableview特定行但特定行包含uibutton。按钮必须访问

Iphone 如何禁用tableview特定行但特定行包含uibutton。按钮必须访问,iphone,uitableview,avaudioplayer,xcode4.6,Iphone,Uitableview,Avaudioplayer,Xcode4.6,我有一个很好的视角 uitableview包含播放列表音频歌曲,我在单元格中放置了一个按钮 用户单击行音频开始播放 我想,当用户点击行时,只有按钮应该是启用的,而单元格应该是禁用的 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ NSURL *url = [[NSURL alloc]initFileURLWithPath:soundsPath];

我有一个很好的视角

uitableview包含播放列表音频歌曲,我在单元格中放置了一个按钮

用户单击行音频开始播放

我想,当用户点击行时,只有按钮应该是启用的,而单元格应该是禁用的

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    NSURL *url = [[NSURL alloc]initFileURLWithPath:soundsPath];

    NSURL *  playurl =[NSURL URLWithString:[passarray objectAtIndex:indexPath.row] relativeToURL:url];

    if (indexPath.row ==1) {

        buybtn.userInteractionEnabled=YES;
        cell.contentView.userInteractionEnabled=YES;
        buybtn.showsTouchWhenHighlighted=YES;
  }
       player = [[AVAudioPlayer alloc] initWithContentsOfURL:playurl error:nil]; 

        [self.player play];
        player.delegate = self;
   cell =[tableView cellForRowAtIndexPath:indexPath];

       cellText = cell.textLabel.text;

    lbl.text=cellText;
     }

这可能会有帮助:在
UITableView的
didselectrowatinexpath:
方法中添加这些代码

添加
标签
特定
按钮
99
,然后

for(UIView *subview in cell.subView)
{
   if(![subview isKindOfClass:[UIButton class]) 
   {
      subview.userInteractionEnabled = NO;
   }
   else
   {
      UIButton *btn = (UIButton *)subview;
      if(btn.tag != 99)
        btn.userInteractionEnabled = NO;
   }
}
编辑:从方法中的
其他
按钮
启用的
特定
按钮

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
将标签分配给您需要访问的按钮:
buybtn.tag=您的标签

然后在didselectrow方法中:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
    UITableViewCell *cell =[tableView cellForRowAtIndexPath:indexPath];

    NSLog(@"sunviews  : %@",cell.subviews);
    for (UIView *_view in cell.subviews) {
        if (_view.tag != YOUR_TAG) {
            [_view setUserInteractionEnabled:NO];
        }
    }
}
希望它能对您有所帮助。

-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{

if(indexPath.row == sepicificRowNumber){

buybtn.userInteractionEnabled=YES;

cell.selectionStyle = UITableViewCellSelectionStyleNone;

}
}

-(void)tableView:(UITableView*)tableView未选择RowatineXpath:(NSIndexPath*)indexPath{

if(indexPath.row == sepicificRowNumber){

//Nothing happen on click   

}
}


希望能有帮助

您想为手机或按钮执行操作吗?@sunny感谢rply按钮的使用bt我的问题是当我单击手机时音频开始播放我不想播放的内容当单击按钮时您想播放音频对吗?我使用按钮购买音频而不是播放音频如果手机中添加了两个按钮,则两个按钮都将启用。但他需要一个特定的按钮才能启用。感谢rply按钮的工作。我的问题是当我点击手机时,音频开始播放我不想要的内容。selectionStyle=UITableViewCellSelectionStyleNone;我在bt之前尝试过它不起作用它的just cell click selection style在用户单击cell时删除蓝色您尝试过:
-(void)tableView:(UITableView*)tableView DidSelectRowatineXpath:(NSIndexPath*)indexPath{if(indexPath.row==sepicificRowNumber){//单击时不会发生任何事情}
这肯定会有帮助。我想禁用可访问的单元格和单元格容器“按钮”:(