1
我正在編程一個基於midi的應用程序。 爲了獲得準確的MIDI時鐘,我使用NSTimer。但在滾動/觸摸子視圖時,NSTimer會凍結。我試圖在子視圖中運行Timer,但同樣的問題。 有沒有人有想法?NSTimer凍結時觸摸UIScrollview
這裏是我的ViewController的代碼:
-(void)timerPlay{
midiclock = [NSTimer scheduledTimerWithTimeInterval:0.5/24 target:self selector:@selector(clocksignal) userInfo:nil repeats:YES];
}
-(void)clocksignal{
beatClock ++;
if (beatClock == 1){
const UInt8 clock[2] = { 0xF8, 0xF9};
[midi sendBytes:clock size:2];
}
if (beatClock == 2){
const UInt8 clock[2] = { 0xF8, 0xF9};
[midi sendBytes:clock size:2];
}
.......
if (beatClock == 24){
const UInt8 clock[2] = { 0xF8, 0xF9};
[midi sendBytes:clock size:2];
beatClock = 1;
}
}
- (void)viewDidLoad {
SubView = [[SubView alloc] initWithNibName:@"SubView" bundle:nil];
[scrollView addSubview:matrixView.view];
......
}
感謝的答案... – Rainer 2011-05-30 14:42:33
我從來沒有與NSThread和循環工作,因爲我不明白... – Rainer 2011-05-30 14:43:25
你能舉一個簡短的例子嗎? – Rainer 2011-05-30 14:43:42