简体   繁体   English

如何以编程方式嵌入视图(即组UI元素)

[英]How to embed in view (i.e. group UI elements) programmatically

In X-Code, I can do "Editor -> Embed In -> View/Scrollview" to group UI widgets together. 在X代码中,我可以执行“编辑器->嵌入->视图/滚动视图”以将UI小部件组合在一起。 How is that done programmatically? 如何以编程方式完成?

Is it same as doing addSubView to a parent view? 与对父视图执行addSubView一样吗?

It is the same . 一样的
For example to add a UILabel to a UIScrollView , simply type myScrollView.addSubview(myLabel) and your label is added to the ScrollView . 例如,要将UILabel添加到UIScrollView ,只需键入myScrollView.addSubview(myLabel)然后将标签添加到ScrollView

Hope that helps :) 希望有帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何以编程方式创建UI元素 - How to create UI elements programmatically 如何以编程方式在视图中嵌入导航控制器? - how to embed navigation controller in a view programmatically? Xcode - 如何在容器视图中以编程方式嵌入/更改视图控制器? - Xcode - How can i programmatically embed/change view controller within a container view? 如何分组ui元素ios - how to group ui elements ios 如何为多个iOS设备(即多个故事板)开发? - How to develop for multiple iOS devices, i.e. multiple storyboards? SwiftUI 相当于 UIViewController 的输入附件视图,即键盘上方的视图始终可见,就像在 iMessage 中一样 - SwiftUI equivalent of input accessory view to a UIViewController, i.e. view above Keyboard is always visible like in iMessage UISplitViewController的详细信息视图中的向左按钮无法显示UITabBarController(即,主视图) - Left Button in UISplitViewController's Detail View Unable to Show UITabBarController (i.e. Master View) 为什么基于应用程序组(即suiteName)的NSUserDefaults返回不同的实例? - Why are app group (i.e. suiteName)-based NSUserDefaults returning different instances? Xcode:如何从以编程方式添加的ui元素中提取数据? - Xcode: How to extract data from programmatically added ui elements? 如何完全重命名 Xcode 项目(即包括文件夹)? - How do I completely rename an Xcode project (i.e. inclusive of folders)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM