- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
UIKit 引用文献说 UIView 是 UIWindow 的父类(super class),但尽管有这种血统,UIWindow 实际上管理 UIView。这对我来说听起来很不寻常。
有谁知道这对软件设计有何意义?
非常感谢。
编辑:
我阅读了 iPhone 编程指南中的相关段落。但我不明白为什么他们会做相反的事情:让 UIWindow 成为 UIView 的父级。肯定有什么事情迫使 Apple 以这种方式设计类层次结构。
最佳答案
One thing that experienced Mac OS X developers may find unusual about the UIWindow class is its inheritance. In Mac OS X, the parent class of NSWindow is NSResponder. In iPhone OS, the parent class of UIWindow is UIView. Thus, in iPhone OS, a window is also a view object. Despite its parentage, you typically treat windows in iPhone OS the same as you would in Mac OS X. That is, you typically do not manipulate the view-related properties of a UIWindow object directly.
编辑:
UIView 是通用的(提供用于创建所有类型的 View 并访问其属性的通用方法。)而 UIWindow 则更具体(类定义管理和协调应用程序在屏幕上显示的窗口的对象。)
我知道有点模糊,我认为只有苹果知道这个层次结构的确切原因。
The UIWindow class defines objects (known as windows ) that manage and coordinate the windows an application displays on the screen. The two principal functions of a window are to provide an area for displaying its views and to distribute events to the views.
The UIView class provides common methods you use to create all types of views and access their properties. For example, unless a subclass has its own designated initializer, you use the initWithFrame: method to create a view. The frame property specifies the origin and size of a view in superview coordinates. The origin of the coordinate system for all views is in the upper-left corner.
UIView objects are arranged within an UIWindow object, in a nested hierarchy of subviews. Parent objects in the view hierarchy are called superviews, and children are called subviews. A view object claims a rectangular region of its enclosing superview, is responsible for all drawing within that region, and is eligible to receive events occurring in it as well. Sibling views are able to overlap without any issues, allowing complex view placement.
关于iphone - 为什么 UIWindow 既是 UView 的子级又是父级?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/830785/
Ember 有一个应用程序,它有 ApplicationView、ApplicationController 和名为“application”的模板和名为“main”的 socket ,所有这些都自动
在我的应用程序中,我在 UIScrollview 中有 UIImageView,我可以毫无问题地放大和缩小。用户可以通过触摸事件在该图像上添加 UIViews。现在拖动图像没有问题.. UIViews
UIKit 引用文献说 UIView 是 UIWindow 的父类(super class),但尽管有这种血统,UIWindow 实际上管理 UIView。这对我来说听起来很不寻常。 有谁知道这对软件
最近得空学习了下uniapp结合vue3搭建跨端项目。之前也有使用uniapp开发过几款聊天/仿抖音/后台管理等项目,但都是基于vue2开发。随着vite.js破局出圈,越来越多的项目偏向于vue3
其实我觉得这个很简单,我漏掉了一些东西。 我正在创建 UIView 的子类,而不是像这样从 ViewController 添加它作为 subview : rateus = RateFrameWork(
我是一名优秀的程序员,十分优秀!