이 이미지 위에 이미지 뷰 및 반투명 버튼이있는 scrollView가 있습니다. 버튼과 이미지 뷰가 [addsubview]로 스크롤 뷰에 추가됩니다. 나는이 버튼 가죽을 한 후스크롤 뷰에서 위치를 변경할 때 UIButton 숨기기
button.frame = CGRectMake(x, y, w, h);
: 는 지금은 (프레임 속성을 변경)
ES를 이미지 뷰 버튼 위치를 변경해야합니다. 단추 위치 만 변경하면 완벽하게 작동합니다.
추신 : 전 bringtofront를 사용하려고했습니다.
있는 ScrollView 컨텐츠 제작 :
int index = 0;
int x = OFFSETXCOPERTINA;
int y = 0;
int w = LARGHEZZACOPERTINA;
int h = ALTEZZACOPERTINA;
int riga = 0;
int indexriga = 0;
int testindex = 0;
if (self.interfaceOrientation == UIInterfaceOrientationPortrait || self.interfaceOrientation ==UIInterfaceOrientationPortraitUpsideDown) {
testindex = NRCopertineVerticale;
}
else {
testindex = NRCopertineOrizzontale;
}
for (NSDictionary *rigaordine in ElencoOrdini)
{
if (indexriga > 0) x = x + OFFSETXCOPERTINA + w;
y = OFFSETYCOPERTINA + (riga * (h + OFFSETYCOPERTINA));
UIButton *buttonCopertina = [UIButton buttonWithType:UIButtonTypeCustom];
buttonCopertina.frame = CGRectMake(x, y, w, h);
[buttonCopertina setBackgroundColor:[UIColor colorWithRed:(255/255.0) green:(255/255.0) blue:(0/255.0) alpha:0.3]];
UIImage *image = [[UIImage alloc] initWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: [NSString stringWithFormat: @"%@image.php?CODe=%@", URLXXX, [rigaordine objectForKey:@"cod_isb"]]]]];
UIImageView *copertina = [[UIImageView alloc] initWithImage: image];
[copertina setTag:TAGCopertine + index];
[copertina setFrame:CGRectMake(x, y, w, h)];
[buttonCopertina setTag:TAGButtonCopertine + index];
[buttonCopertina addTarget:self action:@selector(buttonCopertinaClicked:) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:copertina];
[scrollView addSubview:buttonCopertina];
index++;
indexriga++;
if (indexriga >= testindex) {
indexriga = 0;
riga++;
x = 10;
}
}
내가 아이 패드를 회전 할 때 :
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
int index = 0;
int x = OFFSETXCOPERTINA;
int y = 0;
int w = LARGHEZZACOPERTINA;
int h = ALTEZZACOPERTINA;
int riga = 0;
int indexriga = 0;
int testindex = 0;
if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation ==UIInterfaceOrientationPortraitUpsideDown) {
testindex = NRCopertineVerticale;
}
else {
testindex = NRCopertineOrizzontale;
}
for(int j = 0; j< 999; j++) {
if (indexriga > 0) x = x + OFFSETXCOPERTINA + w;
y = OFFSETYCOPERTINA + (riga * (h + OFFSETYCOPERTINA));
UIImageView *copertina = (UIImageView *)[self.scrollView viewWithTag:(TAGCopertine + j)];
if (copertina != nil) {
copertina.frame = CGRectMake(x, y, LARGHEZZACOPERTINA, ALTEZZACOPERTINA);
}
UIButton *button = (UIButton *)[self.scrollView viewWithTag:(TAGButtonCopertine + j)];
if (button != nil) {
button.frame = CGRectMake(x, y, LARGHEZZACOPERTINA, ALTEZZACOPERTINA);
}
index++;
indexriga++;
if (indexriga >= testindex) {
indexriga = 0;
riga++;
x = 10;
}
}
}
코드를 게시 할 수 있습니까? –
UIButton과 UIScrollView의 관계는 무엇입니까? – Stavash
imageView 및 버튼을 추가하면 코드가 어떻게 표시되고 버튼의 프레임도 어떻게 변경됩니까? – TheTiger