调用UIButton选择器而不触及UIButton

时间:2012-10-28 18:44:00

标签: objective-c ios uibutton ibaction

我可能有一个棘手的问题,希望你能理解这一点:

我有一个带有选择器的UIButton:

- (void)ButtonPressed:(id)sender{
    UIButton *button = (UIButton*) sender;
    int tag = -1;

    if (iniciat == 0){
        if(button.tag == START) {
            tag = 0;
            iniciat = 1;
            [self TimeControl];
        }
    }else{
        switch (button.tag) {
            case START: //Start
                break;
            case LEFT://LEFT  
                //Do sth
                break;
            case RIGHT://RIGHT
                //Do sth
                break;
            default:
                break;
        }

    [super viewDidLoad];

    }
}

但是除了UIButton的触摸动作之外,我还想在完成某些动作时使用/调用此选择器。 我的工作如下:

-(void) checkNXT{
    if (iniciat) {

        aux1 = [NSString stringWithFormat:@"%@", newString];
        bool pressed=[aux1 isEqualToString:@"30a0a00\n"];
        bool pressed2=[aux1 isEqualToString:@"30d0d00\n"];

        if(pressed == TRUE){ //Esquerre
            [self ButtonPressed:buttonLeft];

        }else if(pressed2 == TRUE){
            [self ButtonPressed:buttonRight];

        }

        aux3 = [NSString stringWithFormat:@"%d",count];
    }
    [super viewDidLoad];
}

但不知怎的,它无法正常工作 - >它不会调用函数ButtonPressed。

谢谢!

0 个答案:

没有答案