Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一种情况,我必须使用多个视图(如个人信息 -> 专业信息 -> 流程完成)从用户那里获取输入。
我想知道,如何构建一个像 UIImagePickerController 这样的类,它接受用户的输入并将数据返回给父类?请注意,视图也由此类处理。
这是委托模式的完美示例。
您创建对象,分配委托。该对象允许用户交互。当用户关闭对象视图时,对象告诉委托“这里是选择的值”。
这是 Cocoa 和 Objective-C 中的标准模式,您应该学习使用它,因为您经常遇到它(例如,UITableView 或 UIImagePickerView 都使用委托模式)。