从警报中调用工作表会导致奇怪的窗口问题
我决定使用带有 2 个按钮的警报表。当用户单击“继续”按钮时,应该会落下由窗口制成的纸张。该工作表下降,父窗口与另一工作表一起关闭。我使用的代码是:
- (void)alertDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(int *)contextInfo
{
if (returnCode == kOkayButtonCode) {
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
NSString *status = [defaults objectForKey:@"userStatus"];
if (status == @"NO") {
[NSApp beginSheet:theSheet modalForWindow:window
modalDelegate:self didEndSelector:NULL contextInfo:nil];
}
if (status == @"YES") {
}
}
if (returnCode == kCancelButtonCode) {
[NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.45];
}
}
任何人都可以看到这个问题吗?
I decided to use an alert sheet with 2 buttons. When the user clicks the continue button a sheet made from a window should come down. The sheet comes down and the parent window closes along with the other sheet. The code I'm using is:
- (void)alertDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(int *)contextInfo
{
if (returnCode == kOkayButtonCode) {
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
NSString *status = [defaults objectForKey:@"userStatus"];
if (status == @"NO") {
[NSApp beginSheet:theSheet modalForWindow:window
modalDelegate:self didEndSelector:NULL contextInfo:nil];
}
if (status == @"YES") {
}
}
if (returnCode == kCancelButtonCode) {
[NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.45];
}
}
Can anyone see a problem with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了一个带有计时器的解决方法。
Found a workaround with a timer.