사용자 정의 NSPanel을 작성했으며이를 시트와 함께 표시합니다. 닫기 버튼이 없어 10 초 후에 NSTimer로이 패널을 닫고 싶습니다. 어떻게해야합니까?코코아에서 NSTimer로 사용자 정의 NSPanel을 닫으십시오
[[NSApplication sharedApplication] beginSheet: scanningPanel
modalForWindow: window
modalDelegate: self
didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo: nil];
[[NSApplication sharedApplication] runModalForWindow: scanningPanel];
NSTimer *myTimer = [NSTimer timerWithTimeInterval: 10.0
target:self
selector: @selector(closePanel:) userInfo:nil
repeats:NO];
[[NSRunLoop currentRunLoop] addTimer:myTimer forMode:NSModalPanelRunLoopMode];
closePanel() 함수 :
-(void) closePanel: (NSTimer *) theTimer
{
NSLog(@"closePanel");
[scanningPanel abortModal]; // seems it not work
}
죄송합니다. 귀하의 코드를 모르겠습니다. Add NStimer 또는? –