2017-10-24 9 views
0

저는 iPhone 프로그래밍에서 새로운입니다 (목표 C). 나는 다른 버튼을 길게 누르면 볼 수있는 버튼을 만들고 싶었다. 시스템 키보드 스타일과 같습니다. 나는 그들에게 내 손가락을 쥐고 첫 번째 또는 두 번째 버튼을 선택해야합니다 :-) 나는 어떻게 이것을 할 수 있습니까? 튜토리얼을 찾을 수 없습니다. 감사합니다Objective-C에서 첫 번째 버튼을 누를 때 두 번째 버튼을 표시하는 방법

+2

모습을 처리하는 방법을 만들 –

답변

1

UIButtonUILongPressGestureRecognizer 인스턴스를 만들고 연결하십시오.

-(IBAction)SelectImage:(id)sender 
{ 
     UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressMethod:)]; 
     [self.button addGestureRecognizer:longPress]; 
}  

그런 제스처를 [``UILongPressGestureRecognizer (https://developer.apple.com/documentation/uikit/uilongpressgesturerecognizer?language=objc) 용

- (void)longPressMethod:(UILongPressGestureRecognizer*)gesture 
{ 
    if (gesture.state == UIGestureRecognizerStateEnded) 
    { 
      NSLog(@"Long Press"); 
      //Do your code here what you want to perform 
    } 
}