简体   繁体   English

使用 Xcode 在 Objective-C 中以编程方式在 iOS 中制作 UI 元素

[英]Making UI elements programmatically in iOS using Xcode in Objective-C

I am trying to parse json data and convert it to form in iOS.我正在尝试解析 json 数据并将其转换为 iOS 中的表单。 I am successfully able to parse data and display it, however, i want to fix the UI and make it look more like an iOS form, perhaps using tableviews, etc.我能够成功解析数据并显示它,但是,我想修复 UI 并使其看起来更像 iOS 表单,也许使用 tableviews 等。

How do I approach this?我该如何处理? should I just use a tableviewController or use a tableview?我应该只使用 tableviewController 还是使用 tableview? (the fields are dynamically added, so I have no idea what type and how many fields I will have, until I make a call to the API and fetch the data from the json that I get) (这些字段是动态添加的,所以我不知道我将拥有什么类型和多少字段,直到我调用 API 并从我得到的 json 中获取数据)

Are there any easy to use libraries in iOS that I can use?我可以使用 iOS 中的任何易于使用的库吗?

That's not how UI design works on iOS.这不是 UI 设计在 iOS 上的工作方式。 For the specific example that you mentioned of a tableViewController getting fed from an API... You'll create a tableViewController and you will design a demo cell.对于您提到的从 API 获取tableViewController的特定示例...您将创建一个tableViewController并设计一个演示单元。

Then you will fetch the results from your API, parse it.然后你将从你的 API 中获取结果,解析它。 And you will iterate over the results returned by the API, inside that iteration you will programatically create the table cells (thus ensuring that you are creating as many tables as you need).并且您将迭代 API 返回的结果,在该迭代中,您将以编程方式创建表格单元格(从而确保您根据需要创建尽可能多的表格)。

Nevertheless this is a extremely vague question, and besides briefly explaining how this whole thing works on general terms, there is not much more I can do without you posting the code you have so far.尽管如此,这是一个非常模糊的问题,除了简要解释整个事情如何在一般条件下工作之外,如果没有您发布迄今为止的代码,我无能为力。

Allow me to refer you to this tutorial by NSCookBook that although old is gold when it comes to these things.请允许我向您推荐 NSCookBook 的本教程,尽管在这些方面,旧的就是金子。

Regards,问候,

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM