는 개인적으로 그냥보기 컨트롤러 또는 버튼 서브 클래스 내에서 정수와 버튼의 상태를 추적 할 것입니다. 버튼의 동작을 추적하면 각 동작의 동작을 제어 할 수 있습니다. 이 물건의 일부에하는 .m 파일 던져에 다음
enum {
MyButtonScanning,
MyButtonStalling,
MyButtonIdle
};
@interface YourClass : UIViewController {
NSInteger buttonModeAt;
}
@property (nonatomic) NSInteger buttonModeAt;
-(IBAction)buttonPushedDown:(id)sender;
-(void)tryScanForward:(id)sender;
-(IBAction)buttonReleasedOutside:(id)sender;
-(IBAction)buttonReleasedInside:(id)sender;
@end
를 실행 한 다음,이 같은 물건에 넣어 당신의 .H 파일에서 그 후
@implementation YourClass
///in your .m file
@synthesize buttonModeAt;
///link this to your button's touch down
-(IBAction)buttonPushedDown:(id)sender {
buttonModeAt = MyButtonStalling;
[self performSelector:@selector(tryScanForward:) withObject:nil afterDelay:1.0];
}
-(void)tryScanForward:(id)sender {
if (buttonModeAt == MyButtonStalling) {
///the button was not released so let's start scanning
buttonModeAt = MyButtonScanning;
////your actual scanning code or a call to it can go here
[self startScanForward];
}
}
////you will link this to the button's touch up outside
-(IBAction)buttonReleasedOutside:(id)sender {
if (buttonModeAt == MyButtonScanning) {
///they released the button and stopped scanning forward
[self stopScanForward];
} else if (buttonModeAt == MyButtonStalling) {
///they released the button before the delay period finished
///but it was outside, so we do nothing
}
self.buttonModeAt = MyButtonIdle;
}
////you will link this to the button's touch up inside
-(IBAction)buttonReleasedInside:(id)sender {
if (buttonModeAt == MyButtonScanning) {
///they released the button and stopped scanning forward
[self stopScanForward];
} else if (buttonModeAt == MyButtonStalling) {
///they released the button before the delay period finished so we skip forward
[self skipForward];
}
self.buttonModeAt = MyButtonIdle;
}
단지에있는 버튼의 동작을 연결 내가 IBactions 이전의 논평에서 언급했다. 나는 이것을 테스트하지는 않았지만 효과가있다.
에이 타이머를 무효화하면 클래스에 넣고 빠른 버튼을 만들면 모든 것이 잘 작동하는 것 같습니다. . startScanForward, stopScanForward 및 skipForward 메소드를 추가하기 만하면됩니다. 답장을 보내 주셔서 감사합니다. – mjdth
하지만 아무런 변화가 아직, 엄마 startScanForward 메서드에 문제가있을 수 있습니다, 나는 그만 멈추기 위해 무엇을 해야할지 모르겠다. 나는 ma qn에 ma startScanningForward 메소드를 추가하고 있는데, seekForwards라는 이름을 부여했다. – Nithin
나는이 기능을 가진 간단한 uicontrolviewer를 만들었고 정상적으로 작동합니다. 이렇게하면 단추 자체가 건너 뛰기와 보유를 기반으로하는 탐색을 수행하는 방법에 대한 질문에 대한 대답이됩니다. 실제 파일 자체를 원하십니까? 아니면 스캔/스킵 코드에 문제가 있습니까? – mjdth