UIScrollView에 이미지 묶음을로드하고 크기를 조정하고 각 버튼 위에 위치 시키므로 더 작은 이미지 위에 버튼을 클릭하면 전체 이미지가로드됩니다. 크기 이미지를 새보기로 만듭니다.버튼 매개 변수로 사용자 정의 매개 변수 전달
단추를 클릭 할 때 이미지의 URL을 매개 변수로 전달하고 읽을 때 매개 변수를 콜백 함수에 전달할 수있는 적절한 방법을 찾기 위해 고심하고 있습니다. 여기
내가 지금까지 가지고있는 코드,for(Card *card in crd){
pocketImage = [self imageWithImage:[UIImage imageNamed:@"pocket.png"] scaledToSize:CGSizeMake(245/2,80/2)];
pocketImageView = [[UIImageView alloc] initWithImage:pocketImage];
cardImage = [self maskImage:[UIImage imageNamed:@"animal.jpg"]];
cardImageView = [[UIImageView alloc] initWithImage:cardImage];
y = (80/2) * inc;
if (inc % 2){
x = 125;
} else {
x = 10;
y += (80/2);
}
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn addTarget:self action:@selector(testMe) forControlEvents:UIControlEventTouchUpInside];
[btn setFrame:CGRectMake(x,y-40,pocketImageView.frame.size.width,pocketImageView.frame.size.height*2)];
[pocketImageView setFrame:CGRectMake(x,y,245/2,80/2)];
[cardImageView setFrame:CGRectMake(x,y-40,245/2,80/2)];
//add the pocketImageView to the container
[imageContainer addSubview:cardImageView];
[imageContainer addSubview:pocketImageView];
[imageContainer addSubview:btn];
inc++;
}
콜백 함수,
-(void)testMe {
NSLog(@"works");
}
그래서 기본적으로 그 단지의 모든 이미지를 순환 한 다음 UIScrollView
에 그들 모두를 추가입니다 , 잘 작동합니다 문제는 내가 알 수있는만큼 불가능한 testMe
메서드에 사용자 지정 매개 변수를 전달하려고 할 때 발생합니다. 그러면 어떻게 단추를 클릭 한 다음 해당 전체 크기를 표시 할 수 있습니까? 새로운 v의 이미지 iew?