晚上所有
我有以下代码来填充按钮网格,但是如何检测已选择哪个按钮并将按钮图像传递到另一个控制器
i =0;
int i1=0;
while(i<n){
int yy = 4 +i1*79;
for(int j=0; j<4;j++){
if (i>=n) break;
CGRect rect;
rect = CGRectMake(4+79*j, yy, 75, 75);
UIButton *button=[[UIButton alloc] initWithFrame:rect];
[button setFrame:rect];
id item = [items objectAtIndex:i];
NSString *imageLink = [item objectForKey:@"link"];
UIImage *buttonImageNormal=[UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURLURLWithString: imageLink]]];
[button setBackgroundImage:buttonImageNormal forState:UIControlStateNormal];
button.tag =i;
NSLog(@"index: %i", i);
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside ];
提前致谢