如何以编程方式向AppleWatch添加标签? [英] How to add a label to AppleWatch programmatically?

查看:101
本文介绍了如何以编程方式向AppleWatch添加标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是AppleWatch开发的新手,但是我发现无法以编程方式在AppleWatch屏幕上添加标签(或按钮).我所能做的就是通过情节提要添加资产.

I'm new to AppleWatch development but I find I can't add a label (or button) to AppleWatch screen programmatically. All I can do is just adding the assets via storyboard.

我可以问一下如何以编程方式在屏幕上添加标签或按钮吗?以及如何在屏幕上将其位置设置为x和y?最好使用Objective C解决方案.

Can I ask how to add label or button to the screen programmatically? And how to set their position to x and y on the screen? Objective C solution is preferred.

谢谢!

推荐答案

您不能. Apple Watch开发中的视图层次结构是在编译时在情节提要中静态声明的.如果希望标签在条件上可见,请在情节提要中将其设置为隐藏".然后可以在运行时以编程方式取消隐藏视图.

You can't. View hierarchy in Apple Watch development is statically declared in storyboards at compile time. If you want a label to be conditionally visible, make it in the storyboard and set it to hidden. It is then possible to unhide the view programmatically at runtime.

这篇关于如何以编程方式向AppleWatch添加标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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