zoukankan      html  css  js  c++  java
  • Cocoa 静态显示一个对话框

    M

    //
    //  form2.m
    //  test_multi_window
    //
    //  Created by  on 23/7/14.
    //  Copyright (c) 2014 EDU. All rights reserved.
    //
    
    #import "form2.h"
    
    @interface form2 ()
    
    @end
    
    @implementation form2
    
    - (id)init
    {
        if (![super initWithWindowNibName:@"form2"])
        {
            return nil;
        }
        return self;
    }
    
    
    - (id)initWithWindow:(NSWindow *)window
    {
        self = [super initWithWindow:window];
        if (self) {
            // Initialization code here.
        }
        
        return self;
    }
    
    - (void)windowDidLoad
    {
        [super windowDidLoad];
        
        // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
    }
    
    
    - (IBAction)showWindow:(id)sender
    {
        [[NSApplication sharedApplication] runModalForWindow:self.window];
    }
    
    -(void)closeModalWindow:(id)sender
    {
        [[NSApplication sharedApplication] stopModal];
    }
    
    - (void)windowWillClose:(NSNotification *)notification
    {
        [self performSelectorOnMainThread:@selector(closeModalWindow:) withObject:nil waitUntilDone:NO];
    }
    - (IBAction)OnBT_OK:(id)sender
    {
        [self close];
    }
    
    @end
    


    H

    //
    //  form2.h
    //  test_multi_window
    //
    //  Created by  on 23/7/14.
    //  Copyright (c) 2014 EDU. All rights reserved.
    //
    
    #import <Cocoa/Cocoa.h>
    
    @interface form2 : NSWindowController
    
    @end
    


    调用

    @property (assign) form2 *m_form2;

    在m文件要引用1下

    或者

    @property (retain) form2 *m_form2;

    在m文件要引用1下

    //view

    或者

    @interface EDUAppDelegate : NSObject <NSApplicationDelegate>

    {

        form2 *m_form2;

    }


    - (IBAction)OnBT_Form2_Show:(id)sender

    {

       if (m_form2 == nil)

        {

            m_form2 = [form2 new];

            [m_form2 showWindow:self];

        }

        else

        {

            [m_form2 showWindow:self];

        }


    }




  • 相关阅读:
    postgresql修改postgres用户密码
    centos7 安装netstat命令工具
    sqlplus、lsnrctl命令工具不可用(libclntsh.so.11.1)
    oracle修改数据文件目录
    oracle数据库主主复制
    Spring--quartzJob配置
    TimerTask--spring配置
    SSM+Apache shiro--ehcache缓存清理
    SSM+Apache shiro--自定义realm
    ssm+Apache shiro--配置文件
  • 原文地址:https://www.cnblogs.com/liguangsunls/p/6774644.html
Copyright © 2011-2022 走看看