对于 Cocoa 视图控制器的推送/弹出有什么解决方案吗?
让我解决这个问题:我习惯了 UIKit
,您可以在其中将视图控制器推送/弹出到您想要的内容。这在 Mac 上行不通。
使用 TwUI
,这在 Mac 上运行得非常好。例如,请查看 @joshaber
的 使用 TwUI 的推送/弹出示例。如果 TwUI 完全稳定并且能够在 TUIView 中嵌入 AppKit 控件,我会完全放弃 AppKit。然而,并不是所有的事情都可以在 TwUI
中完成,我需要保留 AppKit 来做一些事情。
因此提出了我的问题。如何使用 AppKit 来完成这样的事情呢?有没有一个图书馆可以让这变得简单?还是需要我们自己做?仅使用 replaceSubview:withSubview:
是不够的,并且并不能真正推送/弹出视图。
Let me get this out of the way: I'm used to to UIKit
, where you can push/pop view controllers to your hearts content. That just doesn't work on the Mac.
With TwUI
, this works extremely well on the Mac. For example, look at @joshaber
's push/pop example using TwUI. If TwUI
was completely stable and capable of embedding AppKit
controls inside a TUIView
, I would ditch AppKit completely. However, not everything can be done in TwUI
, and I need to retain AppKit for some things.
Thus brings my question. How can something like this be accomplished using AppKit? Is there a library that has made this easy? Or do we need to make it ourselves? Just using replaceSubview:withSubview:
isn't enough, and isn't really pushing/popping views.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您问的是如何推送/弹出 NSViews?我在 GitHub 上的 https://github.com/joshaber/ReederDemo 上有另一个示例,它可以做到这一点。您可以从 TwUIPushPopTest 获取 PPNavigationController 的核心内容,并将其替换为在 ReederDemo 中制作动画的内容。它仍然远未完成,但它至少可以让你用一个有点正确的动画来推动和弹出视图控制器。
You're asking about how to push/pop NSViews? I have another example on GitHub at https://github.com/joshaber/ReederDemo that does that. You can take the guts of PPNavigationController from TwUIPushPopTest and replace it with the stuff to do the animation in ReederDemo. It'd still be far from complete, but it'd at least get you pushing and popping view controllers with a kinda-right animation.
啊,我想我找到了我要找的东西。
看
PXNavigationBar
:结合这个和 Josh 的推送/弹出示例,我想出了一个很好的系统。我将保留 Josh 的示例,因为这可以解决根本问题。
Ah, I think I found what I was looking for.
Behold
PXNavigationBar
:Combining this and Josh's push/pop example I've come up with a good system. I'll leave Josh's example selected because that fixes the root problem.