我想看看被点击,所以我可以瓶坯正确的逻辑的按钮。帮助与iPhone按钮按下
这是按钮的代码:
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(270, 423, 60, 60)];
[button addTarget:self action:@selector(buttonPressedAction:)
forControlEvents:UIControlEventTouchUpInside];
[button setBackgroundImage:[[UIImage imageNamed:@"refreshicon.png"]
stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0]
forState:UIControlStateNormal];
button.tag = 1;
UIButton *button2 = [[UIButton alloc] initWithFrame:CGRectMake(0, 423, 60, 60)];
[button2 addTarget:self action:@selector(buttonPressedAction:)
forControlEvents:UIControlEventTouchUpInside];
[button2 setBackgroundImage:[[UIImage imageNamed:@"login.png"]
stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0]
forState:UIControlStateNormal];
button2.tag = 2;
[self.navigationController.view addSubview:button];
[self.navigationController.view addSubview:button2];
这是我如何调用buttonPressedAction
:
- (void)buttonPressedAction:(id)sender
{
UIButton* button = (UIButton*)sender;
if(button.tag == 1)
{
NSLog(@"1");
}else
{
NSLog(@"2");
}
}
但是当我使用NSLog
看到发件人值是什么,它崩溃。
对正在发生的事情以及如何纠正它有什么建议?
现在更正:O)谢谢!
什么是崩溃?无法识别的选择器,还是别的? – 2010-03-23 21:36:10
从什么时候UIButton有一个'value'方法? – Chuck 2010-03-23 21:42:54
我也怀疑一个无法识别的选择器。你期待[发送者值]返回什么?据我所知,UIButton没有像这样的属性。 – 2010-03-23 21:44:36