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

查看:29
本文介绍了如何以编程方式向 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天全站免登陆