我是可可的新手。我想在没有任何按钮的情况下在 iOS 中创建一个相同的可可消息框。NSTimer 后消息框自动关闭。我使用了下面的代码,但它总是添加确定按钮。
alert = [[[NSAlert alloc] init] autorelease];
// [alert addButtonWithTitle: @"OK"];
[alert setMessageText: @"Attention!!! This a critical Alert."];
[alert setInformativeText:@"Scanning..."];
[alert setAlertStyle: NSInformationalAlertStyle];
NSTimer *myTimer = [NSTimer timerWithTimeInterval: 17.0
target:self
selector: @selector(killWindow:) userInfo:nil
repeats:NO];
[[NSRunLoop currentRunLoop] addTimer:myTimer forMode:NSModalPanelRunLoopMode];
int choice = 0;
choice = [alert runModal];
if(choice != 0)
[myTimer invalidate];
KillWindow 函数:
-(void) killWindow: (NSTimer *) theTimer
{
NSLog(@"killWindow");
[[alert window] close];
}
当警报关闭时,我的应用程序无法单击任何按钮或交互?