Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UIView仅嵌入UINavigationController和UIAbbarController,为什么?_Iphone_Ios_View - Fatal编程技术网

Iphone UIView仅嵌入UINavigationController和UIAbbarController,为什么?

Iphone UIView仅嵌入UINavigationController和UIAbbarController,为什么?,iphone,ios,view,Iphone,Ios,View,在iOS中,为什么UIView(和其他)只能嵌入到UINavigationController或UIAbbarController中?这两门课有什么特别之处 编辑:哦,想问“UIViewController”而不是UIView 不,这不是真的。UIView嵌入了UIViewController。此类提供UIView的生命周期。它负责从初始化视图到取消分配视图 UINavigationController和UIAbbarController只是从UIViewController派生出来的。它们分别

在iOS中,为什么UIView(和其他)只能嵌入到UINavigationController或UIAbbarController中?这两门课有什么特别之处


编辑:哦,想问“UIViewController”而不是UIView

不,这不是真的。UIView嵌入了UIViewController。此类提供UIView的生命周期。它负责从初始化视图到取消分配视图


UINavigationController和UIAbbarController只是从UIViewController派生出来的。它们分别为构建层次结构和在层次结构之间切换提供了额外的功能。

UIView可以嵌入到任何ViewController或其子类中。UINavigationController和UITabbarController只是UIViewController的子类。

我认为您所指的嵌入是
embed in
菜单项,它只允许
UITabbarController
UINavigationController
。这意味着XCode将获取您的
UIViewController
子类,并将其嵌入这两个控制器中的一个。它们是特殊的,因为它们是其他控制器(UIViewController的集合)的控制器。Xcode只是减轻了构建视图控制器的一些痛苦,然后将其添加到导航控制器或选项卡栏。您可以轻松地
嵌入其中一个,只需单击一下,无需编写代码。比以前的XCode版本要容易得多。

如果你在Interface Builder中谈论“嵌入”,是的,从iOS 5开始,Interface Builder只为三个视图控制器容器设计了优雅的用户界面,
UINavigationController
uitabarController
UISplitViewController
。这是三个容器控制器,它们都是现成的。不过,您可以自己进行视图控制器包含。有关视图控制器包含的信息,请参见。另请参阅中有关查看控制器安全壳的章节