Cocoa - 将面板滚出窗外?
我希望这非常简单。但基本上我希望我的应用程序能够在应用程序窗口的右侧“推出”面板/视图。
我已经通过以下操作实现了类似的功能(将面板向下滚动到现有窗口上方):
[NSApp beginSheet:myPanel
modalForWindow: [self.view window]
modalDelegate: self
didEndSelector: @selector(sheetDidEnd: returnCode: contextInfo:)
contextInfo: nil];
但是如何才能将面板滚动到窗口的侧面呢?我基本上想要一个侧边栏,如果用户单击该按钮,它将推出并显示更多信息。这有道理吗?
谢谢!
I'm hoping this is ver straightforward. But basically I'd love for my app to be able to "roll out" a Panel/View to the right of my app's window.
I've achieved something similar (rolling a panel down, over the existing window) by doing:
[NSApp beginSheet:myPanel
modalForWindow: [self.view window]
modalDelegate: self
didEndSelector: @selector(sheetDidEnd: returnCode: contextInfo:)
contextInfo: nil];
But how can I have a panel roll out the side of my window? I basically want to have like a sidebar, that if a user clicks the button, it will roll out + display more information. Does that make sense?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有几件事(编辑:好的,三):
首先,其他人建议 NSDrawer,但几年前用户对抽屉的想法充其量是冷淡的。如今,抽屉几乎被普遍鄙视。考虑使用 NSSplitView(带有 1 像素的细边框)并使用它的 -animator 来设置打开/关闭的动画。
其次,如果您特别想要“床单”效果(一张床单似乎从窗户甚至视图中的狭缝中出来),那么您将享受整个定制“乐趣”的世界来重现这种效果,因为有确实没有公共 API 告诉它垂直(相对于水平)从窗口/视图中出来。
第三,我认为以这种方式自定义标准 UI 行为(我的第二点中的工作表示例)几乎永远不是可行的方法。当现有的 UI 不能满足您的需要时,有很多理由提供自定义 UI,但对标准行为进行如此明显的更改往往会遭到其他用户的不满。 Mac 用户。这是他们对第三方 Windows 应用程序的主要抱怨之一(用户界面不一致)。因此,不要为了用户而做垂直工作表的事情。 :-)
Couple of things (Edit: okay, three):
First, others suggested NSDrawer, but users were at best lukewarm on the idea of drawers years ago. These days drawers are nearly universally despised. Consider using NSSplitView (with the thin 1-pixel border) and use its -animator to animate the opening/closing.
Second, if you specifically want the "sheet" effect (a sheet appearing to come out of a slit in the window or even a view), you're in for a whole world of customization "fun" to reproduce this effect, since there's positively no public API to tell it to come out of a window/view vertically (vs. horizontally).
Third, I'd argue customizing a standard UI behavior in this way (the sheet example in my second point) is almost never the way to go. There are plenty of reasons to provide custom UI when the existing doesn't do what you need it to do, but making such an obvious change to standard behavior for the hell of it tends to be frowned upon by Mac users. It's one of the main complaints they have against third-party Windows apps (no consistency in their UI). So don't do the vertical sheet thing for your users' sake. :-)
如果您希望面板从窗口中滚出 - 您应该使用
NSDrawer
。否则 - 你将不得不编写一些自定义的代码,我认为这不会是一个好的用户体验。If you want your panel to roll out away from the window - you should use
NSDrawer
. Otherwise - you'll have to code something custom and I don't think that it's going to be a good UX.