To programmaictlly change the content of app, we need to contect storyboard to a view controller.

To do that, we need to create new file call it 'ProductViewController', subclass should UIViewController:

Delete some uncessary code, the remain code should looks like:

import UIKit

class ProductViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad() }
}

Link view to controller:

Click the view panel, and on the right side give the Custom class name as 'ProductViewController':

Link ui elements to outlets:

Click 'ctrl' & drag the image point to the code:

Give the name and save.

We can use 'Image Literal' to auto select the image:

DO the same for the label,  then the code looks like:

import UIKit

class ProductViewController: UIViewController {

    @IBOutlet weak var productNameLabel: UILabel!
@IBOutlet weak var productViewImage: UIImageView!
override func viewDidLoad() {
super.viewDidLoad() productNameLabel.text = "1937 Desk Phone";
productViewImage.image = #imageLiteral(resourceName: "phone-fullscreen3");
}
}

class CourseViewController : UIViewController {

  @IBOutlet weak var courseNameLabel: UILabel!
@IBOutlet weak var courseImageView: UIImageView! override func viewDidLoad() {
super.viewDidLoad() var courseName = "App Evolution With Swift" courseNameLabel.text = courseName
courseImageView.image = UIImage(named: "course-badge")
}
}

    @IBAction func addProductAction(_ sender: UIButton) {
print("Button tapped")
}

最新文章

  1. android 对sqlite数据库的增删改查等各种操作
  2. sql 中 in与exists的对比
  3. andriod studio
  4. meteor 为基础,联合 Apollo + React + React-Router
  5. SpringMVC Controller 返回值的可选类型
  6. 31.从尾到头输出链表[Print linked list from last to first]
  7. JdbcTemplate 、NamedParameterJdbcTemplate、SimpleJdbcTemplate的区别
  8. mysql case when 条件过滤
  9. JS高级——闭包
  10. JavaScript之ClassName属性学习
  11. 题目1380:lucky number
  12. Android MediaCodec硬编兼容性测试方案
  13. LambdaToSql 发布 兰姆达转换sql
  14. 敏捷开发相关编辑思想(SOA、DDD、REST、CQRS)
  15. DocumentBuilderFactory.newInstance() 异常解决
  16. MVP技术沙龙上海站-SQL BI
  17. 调皮的程序员:Linux之父雕刻在Linux内核中的故事
  18. 照葫芦画瓢系列之Java --- Maven的配置
  19. ansible的管理与剧本
  20. TensorFlow 神经网络相关函数

热门文章

  1. 跟我一起造轮子 手写springmvc
  2. VMware Vsphere 6.0安装部署 vCenter Server安装
  3. iptables---linux防火墙
  4. 调用中行接口针对返回报文(xml形式)做相关处理
  5. 南阳oj 士兵杀敌(二) 题目116 NYOJ 数据结构
  6. hdu 1384 Intervals (差分约束)
  7. 7.Maven之(七)pom.xml配置文件详解
  8. js引入广告服务
  9. DG动态性能视图详解
  10. BZOJ2119: 股市的预测(后缀数组)