我有2个按钮,每个都有标签。我怎么能比较他们之间,每个与他自己的标签和图像。例如:比较两个标记的对象?
// sender is (UIButton *)sender.
if ((sender.tag == 1)theImageOnTheButton == (sender.tag == 2)theImageOnTheButton
{
// egual
}
else
// not egual
所以,如果不是标记为1发件人,他的形象是等于与标签2发送者,他的形象是平等的,等于说,否则,说他们不是egual。我怎样才能做到这一点?
原来的代码是:
-(void)flipView:(UIButton*)sender
{
x = x + 1;
if (x == 1)
{
// When flipping the first card
NSLog(@"X == 1");
[sender setTag:1];
}
else if (x == 2)
{
// When flipping the second card
NSLog(@"X == 2");
x = 0;
[sender setTag:2];
if ((sender.tag == 2) == (sender.tag == 1))
{
NSLog(@"IGUAL");
}
else
{
NSLog(@"NOT EGUAL");
}
}
}
感谢配发。
我认为你需要重新说明你的问题,因为它目前没有任何意义。您发布的代码是可读/有效的语法。 – Dima