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

        }


    }




  • 相关阅读:
    Java解析复杂xml文件,使用Xpath
    表达式求值
    解决 error CS0012 错误
    mssql sqlserver 分组排序函数row_number、rank、dense_rank用法简介及说明
    c#核心基础
    Git源代码管理
    CASE 表达式
    NPM -- 初探--01
    ASP.NET Zero--基础设施
    ASP.NET Zero--基于令牌的认证&SWAGGER UI
  • 原文地址:https://www.cnblogs.com/liguangsunls/p/6774644.html
Copyright © 2011-2022 走看看