【问题标题】:Cocoa App Enter Full ScreenCocoa App进入全屏
【发布时间】:2011-03-09 16:15:39
【问题描述】:

我正在开发一个使用全屏窗口的简单应用程序。

窗口包含包含按钮、图像等的视图...,但是当我使用以下行全屏输入时:

NSWindow* tmp = [self window];
    [tmp setStyleMask:NSBorderlessWindowMask];
    [tmp setFrame:[tmp frameRectForContentRect:[[tmp screen] frame]]display:YES animate:NO];
    [tmp setBackingType:NSBackingStoreBuffered];
    screenRect = [[NSScreen mainScreen] frame];
    int windowLevel = CGShieldingWindowLevel();
    [self.window setLevel:windowLevel]; 

我放在窗口中的视图不会自动调整大小,我可以进行一些正确调整大小的操作,但是有办法自动做到这一点吗?

我在这里发布我所有的 AppController:

 -(id)init {
    self = [super initWithWindowNibName:@"MainWindow"];

    NSWindow* tmp = [self window];
    [tmp setStyleMask:NSBorderlessWindowMask];
    [tmp setFrame:[tmp frameRectForContentRect:[[tmp screen] frame]]display:YES animate:NO];
    [tmp setBackingType:NSBackingStoreBuffered];
    screenRect = [[NSScreen mainScreen] frame];

  /**   
   //  [[tmp standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
   //  [[tmp standardWindowButton:NSWindowZoomButton] setHidden:YES];

    self.window = [[NSWindow alloc] initWithContentRect:screenRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO screen:[NSScreen mainScreen]];
  **/
    int windowLevel = CGShieldingWindowLevel();
    [self.window setLevel:windowLevel];
    return self;
}


// We need to be layer-backed to have subview transitions.
-(void)awakeFromNib {
    [[self window] setContentSize:[topMenu frame].size];
    [[[self window] contentView] addSubview:topMenu];
    [topMenu enterFullScreenMode:[NSScreen mainScreen] withOptions:nil];
    [[[self window] contentView] setWantsLayer:YES];
}


- (void)dealloc
{

    [super dealloc];
}

- (void)windowDidLoad
{
    [super windowDidLoad];

    // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.


    [topMenu_controller performAnimation]; 
    return;


}

【问题讨论】:

    标签: objective-c cocoa macos


    【解决方案1】:

    您可以使用 Interface Builder 的弹簧和支柱来设置视图的自动调整大小行为:

    http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/IB_UserGuide/Layout/Layout.html

    【讨论】:

    • 链接已过期,我要搜索Layout?
    • 您需要设置视图的尺寸属性,使其保持与窗口相同的比例。在 Interface Builder 中选择视图并选择工具 → 显示检查器,然后从检查器窗口顶部的下拉列表中选择大小。检查器窗口的下半部分包含一个标记为 Autosizing 的部分。这些被称为“弹簧和支柱”。单击内部框中的水平线和垂直线,使其变为弹簧。这将导致文本视图的内部大小随窗口增大和缩小。
    • Here's 该文档的存档版本,以及 here's 一些解释 Apple 较新的布局引擎 Auto Layout 的文档。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-03
    • 2011-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多