【发布时间】:2014-03-04 12:46:15
【问题描述】:
我知道我写的代码是错误的。但我想要这样的东西。怎么做?
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
int totalcout = 0;
int passValue ;
for(int j=0; j<5; j++{
for(int i=0; i<5; i++)
{
totalcout++;
if(totalcount >1){
break;
}else{
passValue = i;
}
}
button.tag = j;
[button addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
}
- (IBAction) button:(UIButton *)sender {
NSLog(@"tag numbers are %d", sender.tag);
detailViewController.mutableArray1 = [oneMutableArray objectAtIndex:sender.tag];
detailViewController.mutableArray2 = [twoMutableArray objectAtIndex:passValue];
}
我希望问题很清楚。 提前谢谢你
【问题讨论】:
-
tag1和tag2是什么? -
你想用这两个标签达到什么目的?
-
如果你想为不同的UIButton调用相同的IBAction方法,那么你需要比较IBAction方法中的标签。这是你要找的吗?
-
你想要什么,可以请你更清楚地分享一下
-
您是否只是想将 2 个标签分配给同一个按钮?你为什么要这样做?