我可以创建一个没有故事板的WatchKit应用程序(完全使用代码)吗? [英] Can I create a WatchKit app without a storyboard (entirely in code)?

查看:67
本文介绍了我可以创建一个没有故事板的WatchKit应用程序(完全使用代码)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的团队目前正在开发一个iOS应用程序,我们根本不使用故事板。我们在代码中创建UI。因此,为了保持一致性,如果我们可以完全在代码中创建Watch App目标,那就太棒了。

My team is currently working on an iOS application in which we don't use storyboards at all. We create the UI in code instead. So for consistency's sake it would be great if we could create a Watch App target entirely in code.

但是,WatchKit入门视频和 WatchKit框架参考
提到您需要Watch App目标的故事板。此外,在 WKInterfaceObject.h 中, init 方法被标记为不可用:

However, both the "Getting started with WatchKit" video and WatchKit Framework Reference mention that you need a storyboard for the Watch App target. Furthermore, in WKInterfaceObject.h the init method is marked as unavailable:

- (instancetype)init NS_UNAVAILABLE;

因此,不使用故事板创建Watch App真的不可能吗?如果是这样,这个决定背后的原因是什么?我的意思是,我们可以完全用代码创建一个iPhone / iPad应用程序,那么为什么Watch会有所不同?

So is it really impossible to create a Watch App without using storyboards? If so, what are the reasons behind this decision? I mean, we can create an iPhone / iPad app entirely in code, so why is it different for the Watch?

推荐答案

如果你阅读了 WatchKit编程指南您将看到您的应用程序实际上正在用户的iPhone上执行,并且应用程序通过WatchKit发送要显示给手表的信息。

If you read the WatchKit programming guide you will see that you app is actually executing on the user's iPhone and the app sends information to be displayed to the watch by WatchKit.

由于手表本身没有执行任何代码,因此无法执行编程布局 - WatchKit使用Storyboard提供布局并呈现由您的应用程序在iPhone上运行。

As there is none of your code executing on the watch itself, you can't perform programmatic layout - WatchKit uses a Storyboard to provide the layout and render the information provided by your app running on the iPhone.

Apple已经表示将来可以开发本机Watch应用程序,因此有可能。

Apple has said that it will be possible to develop native Watch applications in the future, so it may be possible then.

这篇关于我可以创建一个没有故事板的WatchKit应用程序(完全使用代码)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆