我想在UIPickerView中选择某些东西时使按钮消失

时间:2015-12-24 03:55:33

标签: objective-c uibutton uipickerview

我想在UIPickerView中选择某些内容时使按钮消失。我已经在.h和.m文件中声明了按钮。所有按钮都正确链接。我将在下面粘贴代码。请帮帮我。

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:  (NSInteger)component
{
    if (pickerView.tag == 1) {

        calculateButtonPressed2.hidden = YES;
        calculateButtonPressed3.hidden = YES;
        calculateButtonPressed4.hidden = YES;
        calculateButtonPressed5.hidden = YES;
        calculateButtonPressed6.hidden = YES;

} else {



}

1 个答案:

答案 0 :(得分:0)

我曾尝试运行代码并发现它正在运行。 如果你想完全消失,那么你可以把下面给出的代码。按钮将消失

 -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{



        if(row>-1) // not required to put but for a safe side we can put it.
       {   
        calculateButtonPressed2.hidden = YES;
        calculateButtonPressed3.hidden = YES;
        calculateButtonPressed4.hidden = YES;
        calculateButtonPressed5.hidden = YES;
        calculateButtonPressed6.hidden = YES;
    } 

//此外,如果您想隐藏在某个特定行上

      if(row== RowNumber){   
            calculateButtonPressed2.hidden = YES;
            calculateButtonPressed3.hidden = YES;
            calculateButtonPressed4.hidden = YES;
            calculateButtonPressed5.hidden = YES;
            calculateButtonPressed6.hidden = YES;
        } 

如果它正常工作,请告诉我。