基于响应 json 以编程方式创建 UIViewController [英] Creating UIViewController programmatically base on response json

查看:22
本文介绍了基于响应 json 以编程方式创建 UIViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我的 json 是

<代码>{{"CategoryID" : "1 个月保费"},{"CategoryID" : "1 年保费"},{"CategoryID" : "1 周保费"},{"CategoryID" : "1 天溢价"},....动态创建的服务器数据.}

我将使用这个库中的 PagingMenuController :

如你所见,我将在 PagingMenu 上显示 CategoryID.每个页面菜单中的所有视图控制器都有共同的项目:

UITableView、UIImageView、UIButton

那么,我如何创建 UIViewController,它在每个视图上都有通用的项目和操作并插入到我的页面控制器中.我真的需要帮助.我不知道如何以编程方式做到这一点.它更像是 google play存储动态创建页面菜单的应用.

有什么帮助吗?拜托,我这辈子只用过故事板和视图控制器.从现在开始,我真的需要帮助.

解决方案

完成以下教程.它在objective-c中,但它会帮助你理解逻辑.

http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/

Assume my json will be

{
      {"CategoryID" : "1 Month Premium"},
      {"CategoryID" : "1 Year Premium"},
      {"CategoryID" : "1 Week Premium"},
      {"CategoryID" : "1 Day Premium"},
      ....Dynamically created server data.
}

And I gonna use PagingMenuController from this library : PagingMenuController

Base on the JSON which I described above, Category will be different,they may be 4 or 5,or more or less.So,Its dynamic.

This is how I gonna develope

As you can see,I will display CategoryID on PagingMenu.All the viewcontroller inside each page menu have common items :

UITableView,UIImageView,UIButton

So,how do i create UIViewController which have common items and actions on each view and insert to my page controller.I really need help with that.I don't know how to do it programatically.It was more like google play store app which page menu are created dynamically.

Any Help?Please,all my life,I used only storyboard and view controller.From now,I really need help.

解决方案

Go through following tutorial. It is in objective-c but it will help you to understand the logic.

http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/

这篇关于基于响应 json 以编程方式创建 UIViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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