UISplitViewController 是否必须是 iPad 应用程序的根控制器?
根据 Apple 关于 UISplitViewController 的文档(在新的 iPad 3.2 SDK 中),看起来他们只打算将其用作应用程序的根控制器。换句话说......看起来你不能将 UISplitViewController 推到 UINavigationController 上,因为显然 UINavigationController 需要保存分割视图。
任何人都可以确认这是否是 UISplitViewController 的真正限制?我希望在我的应用程序中在 UINavigationController 层次结构深处使用分割视图,但看起来我无法做到这一点,除非有办法。
谢谢你!
According to Apple's documentation on the UISplitViewController (in the new iPad 3.2 SDK) it looks like they intend for you to use it only as a root controller of an app. In other words...it seams like you cannot push a UISplitViewController onto a UINavigationController because obviously the UINavigationController would need to hold the split view.
Can anyone confirm if this is a true limitation of the UISplitViewController? I was hoping to use the split view in my app a few levels deep in my UINavigationController hierarchy but it looks like I won't be able to do that unless there is a way.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
每当我尝试以模态方式呈现 UISplitViewController 时,我的应用程序就会崩溃。
My app crashes whenever I try to present a UISplitViewController modally.
这是一篇旧文章,但我发现它有助于我以不同的方式思考,这就是我解决问题的方法。
我以编程方式创建了我的
splitViewController
。然后我用一个数字标记它,并将其作为子视图添加到我当前的视图中。之后,将显示 splitView,但为了摆脱它,我必须将其从视图中删除,因此我在 viewcontrollers 之间创建了一个通知。在主视图控制器中我添加了观察者。 (注意:主视图控制器不是
splitViewController
或其视图之一,它是加载splitViewController
的视图控制器)在选择器“
removeSplitView< /code>" 我将当前视图的所有子视图放入 for 循环中,并搜索带有标签 99 的 UIView 类对象并将其从超级视图中删除。
在第一个View中,我有一个名为done的方法,它发布主
ViewController
正在观察的通知。您还必须在应用中的某个位置创建
fileSelectedNotification
。我通过 viewDidLoad 做到了这一点。看起来像这样。当然,我也将其添加
到此
viewController
的 .h 文件中。因此,当我按下“完成”按钮(这是我的应用程序上的一个栏按钮)时,它会从视图中删除
splitViewController
。工作正常。我只是通过阅读文档得到了这一切。
This is an old post, but i found it useful to help me think in a different way, and this is how i solved the problem.
I created my
splitViewController
programmatically. I then tagged it with a number, and just added it as a subview to my current view.After that,
splitView
is displayed, but to get rid of it, i have to remove it from the view, so i created a notification between theviewcontrollers
. In the main view controller I added the observer. (note: the main view controller isn't thesplitViewController
or one of it's views, it's the view controller that loads thesplitViewController
)in the selector "
removeSplitView
" i put all of the subviews of my current view through a for loop and search for a UIView class object with the tag 99 and remove it from the superview.In the firstView I have a method called done that posts the notification that the main
ViewController
is observing.You'll also have to create the
fileSelectedNotification
somewhere in your app. I did this viaviewDidLoad
. It looks like this.I of course also added this
to the .h file of this
viewController
.Thus, when I push the done button (which is a bar button on my app) it removes the
splitViewController
from view.Works fine. I got all this just from reading docs.
Apple HIG 说你不能。意味着他们可能阻止你这样做,所以我怀疑你能否让它发挥作用。一些开发者已经编写了自己的
Apple HIG says you can't. Means they've probably blocked you from doing it, so I doubt you'll get it working. some devs have written their own
一点也不。例如,可以在层次结构的根部有一个选项卡栏控制器,其中每个选项卡都有一个分割视图控制器。
请参阅我关于将拆分视图控制器改造为选项卡栏界面的文章: http: //markivsblog.blogspot.com/2010/04/retrofitting-ipad-uisplitviewcontroller.html
Not at all. It is possible to have a tab bar controller at the root of the hierarchy, where each tab has a split view controller, for example.
See my post about retrofitting split view controllers to a tab bar interface: http://markivsblog.blogspot.com/2010/04/retrofitting-ipad-uisplitviewcontroller.html
仅供参考,我认为这是要走的路:请参阅类似的问题。
Just for reference, I think this is the way to go: See this similar question.