如何在iphone中的按钮内创建id发送按钮

时间:2012-11-20 08:22:02

标签: iphone

我是iPhone编程的新手。我已经在其中选择了一个按钮,我已经以编程方式创建了另一个按钮,我想使用标签在id发件人按钮内使用多个按钮。现在我做了一些编码,但它是显示一些异常。当我在这里给[self somemethodname:(id)sender];时,我遇到了问题,实际上[self playOrPause]我在另一个按钮中使用了这个。如何解决这个请任何身体告诉我。 感谢

- (void)playOrPause
{
    UIButton *aa = [UIButton buttonWithType:UIButtonTypeCustom]; 
    [aa addTarget:self action:@selector(play:)forControlEvents:UIControlEventTouchUpInside];
    NSLog(@"hi iam 2");
    [self play:(id)sender];
}
-(void)play:(id)sender
{
 UIButton *instanceButton = (UIButton*)sender;
        instanceButton.tag++;
        if (instanceButton.tag == 1) 
        {
            NSLog(@"hi");
        } else if (instanceButton.tag == 2) 
        {
            NSLog(@"hi2");
        } 

  }

0 个答案:

没有答案