문제

I have an IBAction on a button - when it is pressed the method runs as expected.

In that method I update the text label of the button that was pressed.

What i want to happen is when it is repressed I'd like to check the label of the button AND the fact that it was repressed, any ideas how? I'm currently trying to check the state:

if ([buttonName isEqualToString:@"Done"] && (_airlineSelectButtonLabel.state == UIControlEventTouchUpInside)) {
        //Do whatever
    }

Thanks.

도움이 되었습니까?

해결책

I dont see from your question how you retrieved the title on your button, make sure you are using:

NSString *strTitleOnButton = [button titleForState:UIControlStateNormal];

But better use selected property of your UIButton to know if pressed unpressed for example:

- (IBAction)buttonClicked:(UIButton *)sender
{
    if (sender.selected)
    {
        //Already Pressed
    }
    else
    {
        //Unpressed
    }
    sender.selected.toggle()
}

다른 팁

firstly, to get the label of the button use [[sender currentTitle] isEqualToString:@"Done"]; inside your button action.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top