こんにちは私はiPhone開発の初心者です。2つのビューが互いに表示されているかどうかを教えてください。スーパービューをクリックするとドラッグされ、サブビューをクリックするとドラッグされます。誰か助けてもらえますか?
これが私のコードです:
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *aTouch = [touches anyObject];
//UITouch *aTouchSuper = [touches anyObject];
CGPoint location = [aTouch locationInView:self.view];
//CGPoint locationSuper=[aTouchSuper locationInView:viewForTouch];
[UIView beginAnimations:@"Dragging A DraggableView" context:nil];
////////////////////////
//if(location.x>50 &&location.x<300 ){
// viewForTouch.frame = CGRectMake(location.x,0,
// viewForTouch.frame.size.width, viewForTouch.frame.size.height);
//
//
//
// }
UIView *subview = [self.view hitTest:[[touches anyObject] locationInView:self.view] withEvent:nil];
NSLog(@"%i",subview.tag);
if (location.x <= 50)
{
location.x = 50;
}
if (location.x >= 300)
{
location.x = 300;
}
if(subview.tag==12){
viewForTouchInner.frame = CGRectMake(location.x,0,
viewForTouchInner.frame.size.width, viewForTouchInner.frame.size.height);
}
if(subview.tag==11)
{
viewForTouch.frame = CGRectMake(location.x,0,
viewForTouch.frame.size.width, viewForTouch.frame.size.height);
}
///////////////////////
//if(viewForTouchInner.hidden=FALSE){
//
//
//
//
// location.x=0;
// NSLog(@"%f",location.x);
// viewForTouchInner.frame = CGRectMake(location.x,0,
//
// viewForTouch.frame.size.width, viewForTouch.frame.size.height);
//
//
// }
[UIView commitAnimations];
[buttonForMove addTarget:self action:@selector(Show) forControlEvents:UIControlEventTouchUpInside];
}