OSX Lion:全屏和窗口模式下的不同视图 [英] OSX Lion: different views in fullscreen and in windowed mode

查看:181
本文介绍了OSX Lion:全屏和窗口模式下的不同视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使其包含在窗口中的某个视图成为主要内容视图时,当全屏模式切换时,回到只是一部分窗口,当用户离开全屏模式时。



我想出了以下:

   - (void)windowWillEnterFullScreen :(NSNotification *)notification 
{
NSLog(@entering fullscreen);
oldView = [[[[NSApplication sharedApplication] mainWindow] contentView];
[oldView retain];
[[[NSApplication sharedApplication] mainWindow] setContentView:myViewOfInterest];
}

- (void)windowWillExitFullScreen:(NSNotification *)notification
{
[[[NSApplication sharedApplication] mainWindow] setContentView:oldView];
}

但这只适用于第一位:窗口最大化,视图兴趣成为唯一的一个,但当剩下全屏模式时,在全屏模式下唯一可见的视图不再在窗口中。





提前感谢!

解决方案

视图一次只能作为其他视图的子视图。 myViewOfInterest 作为子视图(视图层次结构)中的 oldView 窗户。当你以后恢复 oldView ,你需要添加 myViewOfInterest 回到它是什么(它是什么大小等)。


I'm trying to make it so that a certain view contained in a window becomes the main content view when fullscreen mode is toggled and goes back to taking just a portion of the window when the user leaves fullscreen mode.

I've come up with the following:

- (void)windowWillEnterFullScreen:(NSNotification *)notification
{
    NSLog(@"entering fullscreen");
    oldView = [[[NSApplication sharedApplication] mainWindow] contentView];
    [oldView retain];
    [[[NSApplication sharedApplication] mainWindow] setContentView:myViewOfInterest];
}

-(void)windowWillExitFullScreen:(NSNotification *)notification
{
    [[[NSApplication sharedApplication] mainWindow] setContentView:oldView];
}

However this only works for the first bit: the window maximises and the view of interest becomes the only one, but when fullscreen mode is left, the view that was the only one visible in fullscreen mode is no longer in the window.

I'm very new to Objective-C and Cocoa, so could anyone tell me what am I doing wrong?

Thanks in advance!

解决方案

A view can only be a sub-view to one other view at a time. Your myViewOfInterest is removed as a sub-view (of the view hierarchy) of oldView when you make it the contentView of the window. When you later restore oldView you need to add myViewOfInterest back where it was (and what size it was etc.).

这篇关于OSX Lion:全屏和窗口模式下的不同视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆