2012-02-27 5 views
0

끌기 이벤트에 응답하는 UIButton이있는보기가 있습니다. 그게 다 잘 작동, 문제는 단추가 70X70이며 단추의 이미지가 크게 드래그 할 때 손가락으로 가려집니다 (프로세스는 사용자가 이미지의 대상 영역 (UIButton)을 뷰의 대상 영역으로 끌어다 놓는 것입니다) . UIButton의 중심점이 아니기 때문에 끌기 핸들을 상쇄하는 방법이 있습니까? 이상적으로는 UIbutton의 이미지 오른쪽 상단에 표시해야합니다. 왼쪽 하단은 사용자가 가장 관심이있는 영역이기 때문입니다.UIButton을 드래그 할 때 끌기 핸들 이동

편집 : 나는 이것이 가능하다고 생각하지 않습니다

- (IBAction) imageTouch:(id) sender withEvent:(UIEvent *) event 
{ 
    UIButton *thisButton = (UIButton *)sender; 

    CGPoint centerPoint = [[[event allTouches] anyObject] locationInView:self.view]; 
    UIControl *control = sender; 
    control.center = centerPoint; 

    UIColor *selColor = [WebImageOperations getColorFromImage:self.targetImageView.image atX:point.x andY:point.y]; 

    NSInteger thisScore = [Scoring scoreFromUIColor:selColor withArrow:thisButton.tag]; 

    switch (thisButton.tag) { 
     case 10: 
      arrow10Score = thisScore; 
      self.score10Label.text = [NSString stringWithFormat:@"%d", arrow10Score]; 
      break; 
     case 12: 
      arrow12Score = thisScore; 
      self.score12Label.text = [NSString stringWithFormat:@"%d", arrow12Score]; 
      break; 
     case 14: 
      arrow14Score = thisScore; 
      self.score14Label.text = [NSString stringWithFormat:@"%d", arrow14Score]; 
      break; 

     default: 
      break; 
    } 

    NSInteger totalScore = arrow10Score + arrow12Score + arrow14Score; 
    self.totalScoreLabel.text = [NSString stringWithFormat:@"%d", totalScore]; 
} 
+0

몇 가지 코드를 알려주십시오. – Melvin

+0

거기에가. 코드가 –

+0

일 가능성이 있음 https://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIButton_Class/UIButton/UIButton.html#//apple_ref/occ/instp/UIButton/contentEdgeInsets 또는 https : // developer .apple.com/library/ios/# DOCUMENTATION/UIKit/Reference/UIButton_Class/UIButton/UIButton.html # // apple_ref/occ/instp/UIButton/imageEdgeInsets – Melvin

답변

0

: 여기 터치 (드래그) 이벤트를 처리하기 위해 사용하고있는 코드입니다. 누군가이 문제를 해결하고 해결책을 찾으면 여기에 게시하십시오. 그 답을 올바른 것으로 표시하겠습니다.

관련 문제