버튼 (UIImageViews
)에 터치를 전달하는 하위 클래스 UIScrollView
이 있습니다. ScrollView
에는 페이징이 활성화되어 있으며 프로그래밍 방식으로 2 ~ 7 페이지에 걸쳐 있습니다.UIScrollView는 두 번째 페이지에서만 터치를 허용합니다.
그러나 터치는 페이지 2가 표시된 경우에만 인식됩니다. 스크롤이 잘 작동합니다.
어떤 아이디어? 내가있는 ScrollView를 추가 할 때 다음
는 내가 가지고있는 설정입니다 :lsScroll.pagingEnabled = YES;
[lsScroll setCanCancelContentTouches:NO];
lsScroll.frame = CGRectMake(0, 0, 320, 480);
lsScroll.bounds = CGRectMake(0, 0, 320, 480);
lsScroll.contentSize = CGSizeMake(lsScroll.bounds.size.width, lsScroll.bounds.size.height*maxSection);
[lsScroll setScrollEnabled:YES];
lsScroll.delaysContentTouches = YES;
lsScroll.delegate = self;
lsScroll.bounces = NO;
lsScroll.showsHorizontalScrollIndicator = NO;
lsScroll.showsVerticalScrollIndicator = NO;
lsScroll.clipsToBounds = YES;
(maxSection 어디)
섹션 페이지가 다음 같은 방법으로 추가 된 페이지 수를 정의하는 변수는 다음과 같습니다
section1View = [[UIImageView alloc] initWithFrame:self.view.frame];
section1View.bounds = CGRectMake(0, 0, 320, 480);
section1View.frame = CGRectMake(0, 0, 320, 480);
[section1View setBackgroundColor:[UIColor clearColor]];
[lsScroll addSubview:section1View];
section2View = [[UIView alloc] initWithFrame:self.view.frame];
section2View.bounds = CGRectMake(0, 480, 320, 480);
section2View.frame = CGRectMake(0, 480, 320, 480);
[section2View setBackgroundColor:[UIColor clearColor]];
[lsScroll addSubview:section2View];
section3View = [[UIImageView alloc] initWithFrame:self.view.frame];
section3View.bounds = CGRectMake(0, 960, 320, 480);
section3View.frame = CGRectMake(0, 960, 320, 480);
[section3View setBackgroundColor:[UIColor clearColor]];
[lsScroll addSubview:section3View];
UPDATE : UIImageViews
다음 섹션 #보기의에 추가되고이 난에 접촉을 검사하고있는 객체입니다. 섹션 2View에있는 UIImageViews
은 터치를 등록하지만 다른 섹션의 UIImageViews
은 터치를 등록하지 않습니다.
모든 것이 올바르게 표시되고 정확한 위치에 스크롤이 작동하지만 페이지/섹션 2 작업에서 터치 이벤트가 작동하지만 다른 모든 터치는 실패합니다.
감사의 뜻을 표합니다.
업데이트 : 다음은 'UIImageViews'를 추가하는 코드입니다. 그래서 당신은 내가 이미 이것들로 모든 것이 정확하다는 것을 알 수 있습니다. 첫 번째 페이지는 1 페이지에 나타나는 UIImageViw를위한 것입니다. 2 페이지의 'UIImageView'에 대한 두 번째 터치는 작동하지 않습니다. 코드의
ls1= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ls1.png"]];
ls1.center = (CGPoint){ 215, 65 };
ls1.transform = CGAffineTransformMakeScale(0.33,0.33);
[ls1 setUserInteractionEnabled: YES];
[section1View addSubview: ls1];
ls20= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ls20.png"]];
ls20.center = (CGPoint){ 215, 615 };
ls20.transform = CGAffineTransformMakeScale(0.33,0.33);
[ls20 setUserInteractionEnabled: YES];
[section2View addSubview: ls20];
이 라인은 스프레드 시트에서 매크로를 사용하여 만든 - 그래서 나는 그들이 모두 같은 것을 알고는 모두 setUserInteractionEnabled가 들어 있습니다.
내 업데이트보기 - 이미 모든 UIImageViews에 대해 setUserInteractionEnabled = YES를 설정했습니다. – sregorcinimod
감사합니다. UIView 및 UIImageView로 일부를 넣었습니다. 모두 UIVIew로 전환 한 다음 위에있는 UIImageViews에 터치를 전달합니다. (당신의 실수는 오타 때문에 발생합니다.) – sregorcinimod