x 축 방향으로 만 드래그 가능하도록 설정된 uiimageview를 화면 위로 드래그하면 내 문제가 발생합니다. 코드 작업 종류. uiimageview는 괜찮습니다. x 축에만 제한되어 있습니다. 하지만 uiimageview 프레임 밖으로 드래그를 시작하면 손가락이 움직이지 않습니다.TouchesMoved에 관한 문제 CGRectContainsPoint
이것은이 방법과 관련이 있습니다. CGRectContainsPoint. 마음에 맨 처음에는 사용자가 손가락을 꼈을 때 uiimageview를 움직 이기만하면되므로 코드에서 매우 필요합니다.
이 메서드는 CGRectContainsPoint를 사용하지 않으면 사용자의 손가락이 이미지를 건드리지 않아도 이미지가 계속 이동합니다. 이 문제를 해결하기위한 모든 작업이 많은 도움이됩니다. -(void)touchesMoved:...
에서 -(void)touchesBegan:...
에
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"Touches Moved is running");
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:self.view];
if (CGRectContainsPoint(UIImageView, location) && UIImageView >= 40)
{
NSLog(@"Contains Point UIImageView Center!");
CGPoint xLocation = CGPointMake(location.x,UIImageView);
UIImageView = xLocation;
//here it comes.. big block of code//
if (location.x <= 40) {
NSLog(@"Start Dragging Point");
CGPoint newLocation = CGPointMake(40
, 402);
UIImageView = newLocation;
}
else if(location.x >= 273) {
NSLog(@"End Dragging Point");
CGPoint newLocation = CGPointMake(273
, 402);
UIImageView = newLocation;
}
}
문제가 뭐니? –
문제는 내가 uiimageview를 드래그하고 uiimageview의 프레임 외부에 손가락이 도달 할 때마다 움직이지 않아야한다는 것입니다. 홈 화면 기능을 잠금 해제하려면 ios 6 슬라이드처럼 동작해야합니다. –