iOS 相当于在 Android 中启动 Activity
我刚刚编写完一个 Android Activity,该 Activity 允许其他 Activity 调用它来获取某些结果(它并不打算成为一个独立的 Activity)。我现在正在开发等效的 iOS 应用程序,但找不到任何有关如何在 iOS 上启用类似功能的资源。
情况:我正在生成的工具旨在供其他应用程序使用,而不是作为独立的应用程序。问题是,需要向用户呈现的 GUI 相当复杂,因此我希望能够为开发人员提供一个“一体化”包,他们可以轻松启动并从中获取结果。在 Android 中执行此操作非常简单。我只是编写了一个 Activity 并指示开发人员启动此 Activity 以获得结果。我环顾四周,找不到类似的功能来允许 iOS 开发人员执行相同的操作。这样做的最佳方法是什么?
我认为我在寻找资源时遇到的部分问题是我不完全确定我正在制作的东西叫什么。图书馆?扩大?插件?我认为库没有 GUI,并且扩展和插件似乎是为可扩展应用程序(即用户可以在其中安装扩展/插件的应用程序)制作的。
I just got done writing an Android Activity that allows other Activities to call it for some result (it's not intended to be a stand-alone Activity). I'm now working on the equivalent iOS application and can't find any resources for how I would enable similar functionality on iOS.
The situation: The tool I'm producing is intended to be used by other applications, rather than as a standalone application. The thing is, the GUI that needs to be presented to the user is rather involved so I'd like to be able to provide the developer with a "all-in-one" package that they can simply launch and get results from. Doing this in Android was very straight forward. I simply wrote an Activity and instructed the developer to launch this Activity for result. I've looked around and can't find a similar functionality to allow an iOS developer to do the same. What would be the best way to go about doing this?
I think part of the problem I'm having in finding resources is that I'm not entirely sure what what I'm making is called. A library? extension? plug-in? I would think a library doesn't have a GUI and it seems extensions and plug-ins are made for an extensible application (that is, one in which the user can install the extension/plug-in).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的 API 可以是一个会弹出模式视图的单一调用。可以指定目标和选择器来接收答案。将其提供给其他开发人员意味着将其打包到“框架”中。我不确定您是否可以包含资源。
Your API could be à single call that would pop up a modal view. A target and selector can be specified to receive an answer. Supplying it to other developers means packing it into a "framework". I'm not sure if you can include resources.
确实没有任何等价物。最接近的是让第二个应用程序调用 UIApplication 的
openURL
具有您的应用程序侦听的自定义方案,然后当您的应用程序完成后,它将对调用应用程序侦听的自定义方案执行相同的操作。在实践中,iOS 应用程序通常会包含整个活动等效项作为某种库,它在高层将采用 UIViewController 子类的形式,该子类以模态方式呈现,然后调用某种委托方法或完成选择器完成。
There isn't really any equivalent. The closest you can come is having the second application call UIApplication's
openURL
with a custom scheme that is listened to by your app, and then when your app is done it would do the same with a custom scheme that is listened to by the calling app.In practice, the iOS app would usually include the entire activity-equivalent as some sort of library, which at the high level would take the form of a UIViewController subclass that is presented modally and then calls a delegate method or completion selector of some sort on completion.
iPhone 开发的设计与 Android 开发不同,因此您可能需要重新考虑您想要做什么。
最有可能的是,您最初只想在每个程序中包含代码,这样您就可以对其进行测试,但这可能不是最好的解决方案。
但是,如果不知道您正在尝试做什么的更多细节,就很难给出一些关于更好的解决方案的建议。
例如,您可能会发现
LocalNotifications
作为一种解决方案 (http://useyourloaf.com/blog/2010/7/31/adding-local-notifications-with-ios-4.html),但同样,这取决于根据您的需求。我发现使用本地通知来调用 REST 服务,然后对其进行处理并决定是否需要通知用户很有帮助,可以替代我在 Android 应用程序中使用 Intents 的方式。
iPhone development is a different design than Android development, so you may need to rethink what it is you are trying to do.
Most likely you will want to look at just including the code in each program, initially, just so you can get it testable, but that may not be the best solution.
But, without knowing more details about what you are trying to do it is hard to give some suggestions as to better solutions.
For example, you may find
LocalNotifications
as one solution (http://useyourloaf.com/blog/2010/7/31/adding-local-notifications-with-ios-4.html), but again, it depends on what your needs are.I found that using local notifications to call a REST service, then to process it and decide if I need to inform the user was helpful, as a replacement for how I used Intents in the Android application.