내 UIViewcontroller
에 5 개의 이미지가 Storyboard
에 있습니다. 5 개의 이미지 중 4 개를 손가락으로 화면 (그래프 1,2,3,4)으로 움직일 수 있습니다. 그런 다음 if 문을 만들었습니다. 고정 된 이미지 (최종 그래프) 중 하나를 드래그하면 레이블에 "텍스트"가 나타납니다. 내 진술에서 나는 절편을 썼다. 유일한 문제는 두 이미지가 가로 채 자마자 라벨의 텍스트가 나타나는 것입니다. 그러나 사용자가 손가락을 떼어내어 이미지를 "떨어 뜨리면"나타나게하고 싶습니다. 내가 어떻게 할 수 있니? 답변 주신 여러분 모두에게이벤트
//image movement
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
if ([touch view] == graph1) {
CGPoint location = [touch locationInView:self.view];
graph1.center = location;
[self interceptofgraphs];
}
if ([touch view] == graph2) {
CGPoint location = [touch locationInView:self.view];
graph2.center = location;
[self interceptofgraphs];
}
if ([touch view] == graph3) {
CGPoint location = [touch locationInView:self.view];
graph3.center = location;
[self interceptofgraphs];
}
if ([touch view] == graph4) {
CGPoint location = [touch locationInView:self.view];
graph4.center = location;
[self interceptofgraphs];
}
}
-(void)interceptofgraphs {
if (CGRectIntersectsRect(graph2.frame, finalgraph.frame))
graphlabel.text = [NSString stringWithFormat: @"Right answer. Well done!!"];
if (CGRectIntersectsRect(graph1.frame, finalgraph.frame))
graphlabel.text = [NSString stringWithFormat: @"Wrong!! not at all."];
if (CGRectIntersectsRect(graph3.frame, finalgraph.frame))
graphlabel.text = [NSString stringWithFormat: @"Wrong!! Try again"];
if (CGRectIntersectsRect(graph4.frame, finalgraph.frame))
graphlabel.text = [NSString stringWithFormat: @"Wrong!! NO"];
}
감사합니다 !! : 여기
코드입니다
가 다시 태그; Xcode 문제가 아닙니다. XCode는 IDE 일 뿐이며이 질문은 그와 아무런 관련이 없습니다. – Almo