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];

        }


    }




  • 相关阅读:
    RedHat中代理设置
    CentOS7主机名修改
    ELK+Filebeat+Kafka+ZooKeeper 构建海量日志分析平台
    Zookeeper+Kafka集群部署
    Centos7 中lvs DR配置
    linux抓包命令之tcpdump
    python调用ansible接口API执行命令
    LVS 实现负载均衡原理及安装配置详解
    Ansible 之Playbook
    Linux系统date时间设定
  • 原文地址:https://www.cnblogs.com/liguangsunls/p/6774644.html
Copyright © 2011-2022 走看看