UIScrollview에서 UIImageview를 드래그해야하는 앱을 개발 중입니다. 내 주요 UIView의 맨 아래 부분에 UIImageViews가있는 UIScrollView가 있습니다. 내 PuzzleViewController에서 CustomScroll 객체를 포함하고 인터페이스 빌더의있는 ScrollView에 연결 한 여기에서iphone-UIScrollview 대각선 스 와이프 예상치 못한 동작
@interface CustomScroll : UIScrollView {
}@end
@implementation CustomScroll
- (id)initWithFrame:(CGRect)frame {
return [super initWithFrame:frame];
}
- (void) touchesMoved: (NSSet *) touches withEvent: (UIEvent *) event {
// If not dragging, send event to next responder
if (!self.dragging) {
self.scrollEnabled=NO;
[self.nextResponder touchesMoved:touches withEvent:event];
}
else{
[super touchesMoved: touches withEvent: event];
}
}
- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event {
// If not dragging, send event to next responder
if (!self.dragging)
[self.nextResponder touchesEnded: touches withEvent:event];
else
[super touchesEnded: touches withEvent: event];
}
@end
:
나는 다음과 같은 코드를 사용하여 사용자 정의있는 UIScrollView을 만든@interface PuzzleViewController : UIViewController <UIScrollViewDelegate> {
IBOutlet CustomScroll *segmentScrollview;
}
프로그래밍 방식으로 모든 UIImageviews를 추가했습니다.
이 코드는 예상대로 작동합니다. UIImageview 터치 감지 및 UIView UIScrollview UIImageview 끌 수 있습니다.
하지만 UIImageview를 대각선으로 끌면 문제가 발생합니다.
UIImageview를 scrollview에서 세로로 드래그하면 UIIcageView를 UIView로 옮길 수 있습니다. 그러나 UIImageview를 scrollview에서 대각선으로 드래그하면 UIImageview를 이동할 수 없습니다. 대각선 스 와이프 스크롤 UIScrollview [UIImageview는 변경되지 않았습니다.] 이는 예상치 못한 것입니다. 내가 UIImageview UIScrollview에서 대각선으로 드래그해야합니다.
도움을 주시면 감사하겠습니다.
미리 도움을 청하십시오.
답장을 보내 주신 Sam과 PTBG에게 감사드립니다. 그러나 directionalLockEnabled가 작동하지 않습니다. 문제는 그대로 남습니다. scrollview에서 UIImageview를 대각선으로 끌 수 없습니다. – user392406