- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在构建一个“存在于”NSStatusBar 中的应用程序(没有界面构建器!);当您单击 StatusBar 中的图标时,会出现带有 NSScrollView 的 NSWindow。窗口出现,但似乎有什么东西阻止了用户与 ScrollView 的交互
为了找出问题出在哪里,我还在 AppDelegate 的主窗口 contentView 中添加了我的 View ,奇怪的是 ScrollView 在 MainWindow 中是交互式的......任何人都知道为什么它在我的新窗口中不起作用 window ?
这是我用来创建新的 TTDropDownWindow 的代码:
- (void)openWindow {
// Dropdown
if (self.dropDownWindow == nil) {
self.dropDownWindow = [[TTDropDownWindow alloc] init];
self.dropDownWindow.releasedWhenClosed = NO;
self.dropDownWindow.contentView = self.view;
self.dropDownWindow.backgroundColor = [NSColor clearColor];
self.dropDownWindow.delegate = self;
self.dropDownWindow.alphaValue = 1;
self.dropDownWindow.hasShadow = NO;
self.dropDownWindow.opaque = NO;
}
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
NSRect statusBarContentRect = self.statusBarItemView.window.frame;
NSPoint statusBarOriginPoint = NSMakePoint(NSMidX(statusBarContentRect), NSMinY(statusBarContentRect));
NSRect screenFrame = self.dropDownWindow.screen.frame;
NSRect dropDownContentRect = NSZeroRect;
dropDownContentRect.size.width = DROP_DOWN_WIDTH;
dropDownContentRect.size.height = DROP_DOWN_HEIGHT;
dropDownContentRect.origin.x = statusBarOriginPoint.x - DROP_DOWN_WIDTH / 2;
dropDownContentRect.origin.y = screenFrame.size.height - DROP_DOWN_HEIGHT - NSStatusBar.systemStatusBar.thickness;
[self.dropDownWindow setFrame:dropDownContentRect display:YES];
[self.dropDownWindow makeKeyAndOrderFront:nil];
}
这是 TTDropDownWindow 的实现:
#import "TTDropDownWindow.h"
#import "WFConstants.h"
@implementation TTDropDownWindow
- (id) init
{
self = [super initWithContentRect:NSMakeRect(0, 0, DROP_DOWN_WIDTH, DROP_DOWN_HEIGHT) styleMask:NSBorderlessWindowMask backing:NSBackingStoreRetained defer:NO];
return self;
}
- (BOOL)canBecomeMainWindow {
return YES;
}
- (BOOL)canBecomeKeyWindow {
return YES;
}
@end
这是创建 View 和 ScrollView 的代码
#import "TTStatusBarDropDownView.h"
#import "TTTestView.h"
@implementation TTStatusBarDropDownView
@synthesize dropDownTableViewData = dropDownTableViewData_;
- (id)initWithFrame:(NSRect)frameRect {
self = [super initWithFrame:frameRect];
if (self) {
NSImageView *imageView = [[NSImageView alloc] initWithFrame:frameRect];
imageView.image = [NSImage imageNamed:@"background-dropdown"];
[self addSubview:imageView];
// first create a view to put in a ScrollView
NSView *scrollViewHolder = [[TTTestView alloc] initWithFrame:NSMakeRect(19, 98, 414, 543) andColor:[NSColor yellowColor]];
[self addSubview:scrollViewHolder];
// create the scrollView
NSScrollView *scrollView = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 414, 543)];
scrollView.hasVerticalRuler = YES;
scrollView.hasVerticalScroller = YES;
[scrollViewHolder addSubview:scrollView];
// TTTestView is just a NSView with a background drawing
TTTestView *theViewThatScrolls = [[TTTestView alloc] initWithFrame:NSMakeRect(0, 0, 200, 10000) andColor:[NSColor blueColor]];
[theViewThatScrolls addSubview:[[TTTestView alloc] initWithFrame:NSMakeRect(10, 10, 100, 8000) andColor:[NSColor grayColor]]];
[scrollView setDocumentView:theViewThatScrolls];
}
return self;
}
@end
最佳答案
您可以按照此处所述将 NSBackingStoreRetained 更改为 NSBackingStoreBuffered: NSScrollView in a NSWindow
关于objective-c - 使用 NSScrollView 在新的 NSWindow 中没有滚动或用户交互,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9032619/
我有一个主窗口,它是我的应用程序的中心。对于不同的功能,我打开一个子窗口来处理某些专门的功能。我希望所有窗口都能独立移动,但现在如果我移动原始的中央窗口,那么所有这些子窗口都会随之移动。如何使子窗口断
当我打开自动释放的 NSWindow 时,一切正常。仅当我单击“确定”按钮后,NSWindow 才会由我的根类释放。 但是,当我打开一个 NSWindow 并从打开的 NSWindow 打开一个新的
这两个委托(delegate)方法在 NSWindow 开始移动之前或 NSWindow 停止移动之后调用。 -(void)windowWillMove:(NSNotification *)notif
我想在 NSWebView 上添加一些 UI 控件,由于这个问题“https://stackoverflow.com/questions/9120868/video-in-nswebview-hide
因此,我正在构建一个程序,该程序的特点是使用 IKImageBrowserView 组件作为 NSWindow 中的 subview 。作为旁注,我有一个名为 ImageBrowserControll
我需要在第一次运行后显示主窗口后立即显示一个工作表对话框。如果我在 init 中执行此操作或从 nib 中唤醒,它似乎无法正常工作(如果我在 init 方法中执行此操作,则工作表显示为与主窗口分离的窗
对于高技能的 Cocoa 程序员来说,这可能是一个简单的问题,但我找不到如何在单独的窗口中控制图形。我仔细阅读了Cocoa相关的书籍,浏览了很多网络笔记,但我找不到解决我的问题的方法。目的是使用专用窗
在 OS X 上是否可以通过编程方式访问缩放或最大化窗口的恢复窗口位置。 即:在大多数 OS X 应用程序中,您可以双击标题栏来缩放它。如果您再次双击它,它会恢复到之前的位置。 我希望能够获取和设置保
我正在以编程方式创建一个需要跨越 2 个屏幕的窗口。正在创建的窗口的大小是正确的,但窗口大约从第一个屏幕的一半开始。我可以将它拖回第一个屏幕的开头,NSWindow 非常适合。 我只需要知道在窗口的起
在 Creating a custom title bar on a standard NSWindow 的帮助下,我一直在尝试为 NSWindow 创建自定义标题栏. NSView *themeFr
当主(唯一)关闭时,如何正确退出 Mac OS X 应用程序? 我知道有一个方法- (void)windowWillClose:(NSNotification *)notification在 NSWi
我有自定义 NSWindow,自定义 NSView 设置为它的 contentView。 窗口被初始化为: [window setOpaque:NO]; [window setBackgroundCo
我正在 Xcode5 中为 Mac OSX 开发一个应用程序 我想全屏显示我的第一个窗口(没有工具栏只是我的 View ) 我找到了一种在角落显示全屏按钮的方法: AppDelegate.m: - (
当 NSWindow 尝试关闭时如何显示 NSAlert?这也必须打开和关闭。 最佳答案 NSWindow 的委托(delegate)有一个 windowShouldClose:方法将允许您自定义它。
Thread Safety Summary developer.apple.com 上声明 NSWindow 是线程安全的*并且可以从工作线程创建。 我有一个工作线程,我创建得相当简单: [NST
我正在尝试创建一个我创建的窗口来接受从取景器拖放到其上的文件,当我尝试将文件拖到窗口上时发生的所有情况都是它会弹回到桌面上的位置。显然我没有设置正确的东西。 在NSWindowController:i
我的 Cocoa 应用程序在屏幕上显示一个透明窗口,但是当用户尝试使用 Mac OS X 的内置屏幕捕获键并可选择选择完整窗口(Command-Shift-4,然后空格键)进行屏幕截图时),我的窗口被
我正在实现一个支持全屏模式的Cocoa应用程序。如果用户在全屏模式下工作时退出,我需要以全屏模式启动应用程序, 启动应用程序时,我检查应用程序是否应以全屏模式启动,然后在 NSWindow 上调用 t
在常见情况下,应用程序的布局将是 TITLE 位于顶部,ViewController 位于底部。但是,我想让我的应用程序具有左右显示功能。 使用分割 View Controller ,标题仍将位于所有
NSWindow 关闭后如何获取事件或通知?我能找到的最近的东西是 NSWindowDelegate 中的 windowWillClose: 方法。但这个方法是在 NSWindow 即将关闭时调用的,
我是一名优秀的程序员,十分优秀!