this stackoverflow entry을 적용하여 하나의보기에서 다른보기로 이동할 때 터치를 감지 할 수 있습니다.touchesMoved : withEvent : 응답을 멈 춥니 다
하위보기가 실제로 터치를 감지합니다. 그러나, 나는 더 많은 것을하고있다. 부모보기에서 터치를 제거하고 부모보기에 새보기를 추가하는 것을 감지 한보기가 필요합니다. 그래서 다음과 같은 것을 가지고 있습니다 :
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self.contentView];
for (UIView *view in self.contentView.subviews)
{
if ([view isKindOfClass:[MyCustomView class]] &&
CGRectContainsPoint(view.frame, touchLocation))
{
[view removeFromSuperview];
UIView *aNewView = [[[UIView alloc] initWithFrame:someFrame] autorelease];
[self.contentView addSubview:aNewView];
}
}
}
if 문을 통과 한 후 앱이 터치 동작에 응답하지 않습니다. 문제가 뭐라고 생각하니? 그 원인은? [view removeFromSuperview]
?
self.contentView를 삭제 하시겠습니까 ?? – iPatel
MyCustomView userintraction을 사용할 수 있습니까? –
얼마나 많은'MyCustomView' 뷰가 contentView에 있습니까? 이 메서드는 주 스레드에서 호출되므로 무거운 계산을 수행하면 메서드가 종료 될 때까지 앱이 응답하지 않는 것처럼 보입니다. –