2012-05-16 2 views
0

펜촉에서보기를로드하고 기본보기에 추가하려고합니다. 여기 내 코드가있다. 내가보기를 초기화하기 및 기본보기에 추가 그 후펜촉에서로드 된보기가 터치 이벤트를 수신하지 않습니다.

- (id)initWithFrame:(CGRect)frame 
    { 
    self = [super initWithFrame:frame]; 
    if (self) { 
     NSLog(@"init with frame"); 
     // Initialization code 

     NSArray *addTaskArrayOfViews = [[NSBundle mainBundle] loadNibNamed:@"AddTaskView" 
                    owner:self 
                    options:nil]; 
     self=[addTaskArrayOfViews objectAtIndex:0]; 
    } 
    return self; 
    } 

:

self.addTaskView=[[AddTaskView alloc]initWithFrame:CGRectMake(0, 0, 320, 460)]; 
    [self.view addSubview:self.addTaskView]; 

모든 것이 잘 작동하지만 AddTaskView는 아무튼

나는하여 @interface AddTaskView:UIViewinitWithFrame에 펜촉을로드 터치 이벤트를 수신하지 못합니다. 나는 세 개의 버튼을 가지고 있으며 그들을 밀어 붙이려고 할 때 행동을받지 못한다. "AddTaskView"유형의 펜촉을 만들었지 만 운이 없다. 나는 또한 하위 뷰를 보았고 "AddTaskView"가 상위 뷰이다.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ 
     NSLog(@"touch"); 
    } 

가 어떻게 터치 이벤트에 응답 할 수있는 기회를 얻을 수 있습니까 :

은 내가 터치없이 응답을 얻을 수 있는지 확인하기 위해 AddTaskView이 코드를 추가?

답변

0
[UIView beginAnimations:@"MoveAndStrech" context:nil]; 

[UIView setAnimationDuration:1]; 

[UIView setAnimationBeginsFromCurrentState:YES]; 

[UIView commitAnimations]; 
+0

코드입니다 다음 .... 당신은 터치 디스패처를 등록하고 터치를 얻기 위해 시도해야 할 것 같아? 이 질문에 어떻게 대답합니까? – Krishnabhadra

0

난 당신이 다른 질문에 대답하고 있는지

-(void)registerWithTouchDispatcher{ 
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0swallowsTouches:YES];} 

-(BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event{ 
return YES;} 

-(void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event{ 
touchLocation = [touch locationInView:[touch view]]; 
NSLog(@"Touch is working");} 
관련 문제