iOS:Objective C 中的库可以生成弹出窗口并管理交互吗?
我想在库中创建一个类,该类将根据请求与用户进行复杂的交互。初始化库的应用程序不会提供任何信息,例如 UIWindow 或任何内容。这在技术上可能吗?我知道我可以做一个简单的弹出窗口,但是如果需要动态构建一些东西呢?谢谢。
I want to make a class in a library that will, upon request, do a complicated interaction with the user. The app that initializes the library will not provide any info like its UIWindow or anything. Is this technically possible? I know I can do a simple popup but what about something that needs to be constructed on the fly? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的库将可以访问像
[UIApplication sharedApplication]
这样的单例,因此如果您想向用户展示某些内容,您可以直接将视图添加到窗口:也许更好的方法是展示不过,它是在视图控制器内模态地进行的。
Your library will have access to singletons like
[UIApplication sharedApplication]
, so if you want to present something to the user, you can just add your view to the window directly:Perhaps a better way would be to present it modally from within a view controller, though.
使用 UIViewController 进行任何复杂的用户交互。为了以模态方式呈现视图控制器,您必须找到合适的父视图控制器。
您可以使用
UIWindow
的-rootViewController
方法访问应用程序的根视图控制器,如下所示:您还可以提供委托方法并使用它来获取视图控制器:
在您的库中,您可以访问委托并访问视图控制器,如下所示:
Use
UIViewController
for any complex user interaction. In order to present a view controller modally, you'll have to find a suitable parent view controller.You can get access to the app's root view controller using the
-rootViewController
method ofUIWindow
like that:You can also provide a delegate method and use this to get a view controller:
In your library you have access to the delegate and access the view controller like that: